ASPxGridView PerformCallback() does full page postback - asp.net

I have a checkbox that when clicked, calls a javascript program that calls grid.PerformCallback(), where grid is the client instance name of my ASPxGridView gridview. This gridview also has a custom callback method which databinds the table. However when i click my checkbox, instead of only performing callback on the gridview, my page does a full postback, which posts the form. How do i make it so that it only updates the gridview?
function toggle()
{
productGrid.PerformCallback();
}//end toggleExch()
<dx:ASPxGridView ClientInstanceName="productGrid" Width="100%" ID="productGrid" runat="server"
DataSourceID="ProductSQL" EnableCallBacks="true" OnCustomCallback="productGrid_OnCustomCallback">
</dx:ASPxGridView>
protected void productGrid_OnCustomCallback(object sender,
DevExpress.Web.ASPxGridView.ASPxGridViewCustomCallbackEventArgs e)
{
System.Diagnostics.Debug.WriteLine("in postback");
productGrid.DataBind();
}//end productGrid_OnCustomCallback()
so basically the debug line is not printed and the page goes into full postback - how do i only postback and databind the grid? (i need to do more server side processing before databinding or directly binding from jquery is out of the question)

found the answer - should use iscallback instead of ispostback

Unfortunately, you did not post the aspx markup of the button. However, if this is the ASPxButton, make certain that its AutoPostback property is false ...

Related

get selected index of databound list control on user control

I have a radiobuttonlist that lives on a user control. This user control lives in a repeater on a parent user control, and that user control lives on a page with a submit button.
So something like this:
<page>
<UserControl1>
<Repeater>
<UserControl2>
<radiobuttonlist>
</UserControl2>
</Repeater>
</UserControl1>
<Submit button />
</page>
The radiobuttonlist is dynamically populated in the code-behind of UserControl2. The problem is that when I submit the form, I need to access the SelectedValue of the radiobuttonlist, and that value is always empty. Even if I first fire the methods that populate the radiobuttonlist, the selectedvalue of the RBL is empty. I have a SelectedIndexChanged event handler on the RBL, but it never fires.
What do I need to do to be able to get the SelectedValue of the radiobuttonlist when I cause the parent page to postback?
I got it working. I guess it was an order of operations issue. The fix was to dynamically declare the event handler of the radiobuttonlist in the OnInit() of UserControl2.
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
rblOptions.SelectedIndexChanged += new EventHandler(ctrlOptions_SelectedIndexChanged);
}
Once I did that, the event started firing, even though I was re-instantiating the UserControl on postback. Since the event was firing, I was able to obtain the Selected Index without needing to keep it in ViewState.
When you post your datas, you re-bind your datas so you erase your selected event or values.
Try with this code in your Page_Load (Of your User Control)
If(! IsPostBack)
{
//You build RadioButtonList
}
And persist your datas with ViewState, EnableViewState="true"

Issue with getting control id when tabcontainer is used

I have an AJAX Control Toolkit TabContainer in my ASP.NET page. In one of the tabs in the TabContainer, there is a GridView. Now, I have an UpdatePanel for which I want to give trigger as "RowCommand" of GridView mentioned above. The UpdatePanel is outside the TabContainer. But when I give the GridView id, I am getting the error:
A control with ID 'grvSummary' could not be found for the trigger in UpdatePanel 'updSegment'.
Trigger markup:
<asp:AsyncPostBackTrigger ControlID="grvSummary" EventName="RowCommand" />
You will have to programmatically add the trigger to your UpdatePanel. This is because your GridView may or may not start in a different ContentPlaceHolder than the UpdatePanel (namely, the <ContentTemplate> of your TabContainer). Like this (note that this really needs to be done in Page_Init, due to the Page Life Cycle):
protected void Page_Init(object sender, EventArgs e)
{
AsyncPostBackTrigger trig = new AsyncPostBackTrigger();
trig.ControlID = grvSummary.UniqueID;
trig.EventName = "RowCommand";
updSegment.Triggers.Add(trig);
}
It looks like this may be a problem with ASP.NET / AJAX assuming the wrong Control.UniqueID value for the Control being used as a trigger.
Source: Triggering an UpdatePanel in a different ContentPlaceHolder

ASP.NET [Need an event after page load (After GridView renew data) ]

I renew parameters of my DataSource for GridView on Button and loads event Page_Load()
and After it (or with it) GridView renews itself.
I need to rename Header rows but there is no event after Page Load.
more information about details here :
[On Button Click] I change DataSource and Bind it (SqlDataSource1.DataBind(); ) Then sure Page gone to Refresh elements.
[On Page_Load] GridView is changing data, but if I can't change Headers there because it's looking like loads after this function :(
[one more Button] I can add new button with a function - rename headers and it works correct everytime
protected void Button2_Click(object sender, EventArgs e)
{
// Stack overflow
DataRow T;
if (go)
if (GridView2.HeaderRow.Cells.Count != 0)
for (int i = 0; i < SQF.SQF.Permission.Rows.Count; i++)
{
T = SQF.SQF.Permission.Rows[i];
GridView2.HeaderRow.Cells[i].Text = (string)T["Caption1"];
WebMsgBox.Show((string)T["Caption1"]);
}
}
Trouble : I no need one more button for it, I need to rename header rows after I click button to change Data but I have no idea where I can do it.
thank you.
Well you could use Gridview DataBound event, like that:
<asp:GridView runat="server" ID="SomeID" OnDataBound="GridVIew_OnDataBound" ... />
The DataBound event occurs right after the databinding process for that particular control has completed.
After Page_Load there is an event Page.PreRender.
Maybe it will suit you.
EDIT.
All events of your components, such as GridView, are fired between Page.Load and Page.PreRender. Consider using RowDataBound and RowUpdated events.

LinkButton (inside a Panel, but outside of UpdatePanel) OnClick event not causing parent page PostBack?

Using VS2005, ASP.Net 2.0, AjaxControlToolKit
I have a LinkButton in a Panel that contains an UpdatePanel with a GridView. The link button is outside the UpdatePanel. The OnClick event has this code:
protected void lnkOk_Click(object sender, EventArgs e)
{
foreach (GridViewRow row in grdProductSearch.Rows)
{
CheckBox chk = row.Cells[0].Controls[0] as CheckBox;
if (chk != null && chk.Checked)
{
// ...
}
}
Server.Transfer(Page.Request.RawUrl);
}
I need it to pass the selected values of the grid back to the Parent page in a post back. But all it does is close the Panel.
Any ideas why this is happening? or how can I achieve what I am trying to do?
Try putting everything inside the UpdatePanel. Sometimes this control messes up the page normal behavior.
I've seen several times that UpdatePanel control affect somehow (it's difficult to say where and how) the javascript of the page. For example, When you have the UpdatePanel declared as ChildrenAsTriggers="false" and declared AsyncPostBack triggers, if you have a Validation Summary inside, it never shows the validation errors done in the server.

Inline Data-Binding asp.net tags not executing

My problem is I used to be able to do this,
< div runat="server" visible='<%#CallAFunctionThatReturnsBoolean() %>' >
and CallAFunctionThatReturnsBoolean() will be called in Page_Load when the control's DataBind function gets called implicitly and the div's visibility will be set correctly.
Now for some reason this doesn't happen anymore, and to make it work I would have to either call Page.DataBind() in my base Page class or Me.DataBind() in the Page_Load sub in that page, but I don't really want to do this, especially in the base Page class because then if I have a page with let's say a DataGrid in it that I already call the DataBind() function explicitly, then this DataGrid will get bound twice, once from Page.DateBind and once from the explicit call datagrid.DataBind().
Any idea why the control's data binding event is not called implicitly anymore?
Thanks
The <%# happens for databinding, the <%= will happen always when the page is being built reglardless of any databinding. It sounds like that is what you are looking for?
Also databinding is control level so if you 'DataBind' a grid, it will not databind any other controls. Even embedded templated controls will not be automatically databound when the grid is called unless you wire the up to do so.
Try doing the following and see if it corrects your problem:
<div runat="server" visible='<%= CallAFunctionThatReturnsBoolean() ? "true" : "false" %>' >
If you require it to occur in the databinding event, I prefer to implement OnDataBinding server side as follows:
// in your aspx
<div runat="server" OnDataBinding="yourDiv_DataBinding">
// in your .cs
protected void yourDiv_DataBinding(object sender, EventArgs e)
{
HtmlControl div = (HtmlControl)(sender);
div.Visible = CallAFunctionThatReturnsBoolean();
}

Resources