Scenario
--I have a drop down
--On select changed event of drop down ...grid populates....allow paging is made true
--When i navigate to second page i get error
Microsoft Jscript Runtime error:
system.webform.pagerequestmanagerservererrorexception :
The gridview 'GridzeroApprovedKm' fired event PageIndexChanging which wasnt handled.
-----------------------------------------------aspx page------------------------------
<asp:GridView ID="GridZeroApprovedKm" AllowPaging="true" runat="server" AutoGenerateColumns="false"
DataKeyNames="Address_id" OnRowCancelingEdit="GridZeroApprovedKm_RowCancelingEdit"
OnRowDataBound="GridZeroApprovedKm_RowDataBound" OnRowDeleting="GridZeroApprovedKm_RowDeleting"
OnRowEditing="GridZeroApprovedKm_RowEditing"
OnRowUpdating="GridZeroApprovedKm_RowUpdating"
onpageindexchanging="GridZeroApprovedKm_PageIndexChanging">
-------------------Code Behind - Populating the GridView -----------------------------
--here the grid popultes
protected void ddlhub_SelectedIndexChanged(object sender, EventArgs e)
{
TMS.Business.INT_ApprovedKm ApprovedKmObjdis = new TMS.Business.INT_ApprovedKm();
DataSet Approveddata = new DataSet();
Approveddata = ApprovedKmObjdis.GetZeroApprovedKm(ddlhub.SelectedValue);
GridZeroApprovedKm.DataSource = Approveddata;
GridZeroApprovedKm.DataBind();
}
----------------------PageIndexChange Event Handler of GridView----------------
protected void GridZeroApprovedKm_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridZeroApprovedKm.PageIndex= e.NewPageIndex;
TMS.Business.INT_ApprovedKm ApprovedKmObjdis = new TMS.Business.INT_ApprovedKm();
DataSet Approveddata = new DataSet();
Approveddata = ApprovedKmObjdis.GetZeroApprovedKm(ddlhub.SelectedValue);
GridZeroApprovedKm.DataSource = Approveddata;
GridZeroApprovedKm.DataBind();
}
Again I am trying to populate the grid by writing the above code.
Where i am doing wrong ?
---what i understand is
when i navigate to next page. the dropdown is having "select" but not the value that is selected in first page.
--so that may be the reason why its not working
--if this is the problem....then when i navigate to next page....the drop down should be selected as it was selected as in first page...so that the selected change event will fire and the grid will populate
--correct me if i am wrong
--also please tell me how to solve this
--this is my page load event
protected void Page_Load(object sender, EventArgs e)
{
try
{
if (!Page.IsPostBack)
{
ControlBinding.FillCombo(ddlhub, "HUB_MASTER", Session[TMS.Common.CommonConstants.CONST_COMPANY_ID].ToString(), Session[TMS.Common.CommonConstants.CONST_USER_HUB_ID].ToString(), Session[TMS.Common.CommonConstants.CONST_USER_ID].ToString(), "", "", "", false);
}
for (int count = 0; count < ddlhub.Items.Count; count++)
{
ddlhub.Items[count].Attributes.Add("title", ddlhub.Items[count].Text);
}
}
catch (Exception ex)
{
LogError.WriteError(ex);
}
finally
{
}
}
--update panel i am using in aspx page
<asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" runat="server">
<ContentTemplate>
<asp:GridView ID="GridZeroApprovedKm" AllowPaging="true" runat="server" AutoGenerateColumns="false"
DataKeyNames="Address_id" OnRowCancelingEdit="GridZeroApprovedKm_RowCancelingEdit"
OnRowDataBound="GridZeroApprovedKm_RowDataBound" OnRowDeleting="GridZeroApprovedKm_RowDeleting"
OnRowEditing="GridZeroApprovedKm_RowEditing"
OnRowUpdating="GridZeroApprovedKm_RowUpdating"
onpageindexchanging="GridZeroApprovedKm_PageIndexChanging">
<SelectedRowStyle CssClass="ResultSelectedRow" BackColor="Cyan" />
<Columns>
<asp:TemplateField HeaderText="Select All">
<HeaderTemplate>
<asp:CheckBox ID="chkb1" runat="server" Text="Select All" OnCheckedChanged="sellectAll"
AutoPostBack="true" />
</HeaderTemplate>
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
<ItemTemplate>
<asp:CheckBox ID="chkb2" runat="server" OnCheckedChanged="sellectAllChildcheckbox" Text="Select" AutoPostBack="true" />
</ItemTemplate>
<ItemStyle HorizontalAlign="center" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Hub Name">
<ItemTemplate>
<asp:Label ID="lbladdressid" runat="server" Visible="false" Text='<%#Eval("Address_Id") %>'></asp:Label>
<asp:Label ID="lblhubname" runat="server" Visible="true" Text='<%#Eval("hub_name") %>'></asp:Label>
</ItemTemplate>
<ItemStyle HorizontalAlign="center" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Location">
<ItemTemplate>
<asp:Label ID="lblgeocodeaddress" runat="server" Visible="true" Text='<%#Eval("geocode_address") %>'></asp:Label>
</ItemTemplate>
<ItemStyle HorizontalAlign="center" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Approved Km By Ops">
<ItemTemplate>
<asp:TextBox ID="txtdistanceops" MaxLength="6" CssClass="textBox_for6tds" runat="server"> </asp:TextBox>
<asp:RegularExpressionValidator ID="revtxtdistanceops" runat="server" Display="Static"
SetFocusOnError="True" ValidationExpression="[0-9]*\.?[0-9]*" ControlToValidate="txtdistanceops"></asp:RegularExpressionValidator>
</ItemTemplate>
<ItemStyle HorizontalAlign="center" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Approved Km By CTV" Visible="false">
<ItemTemplate>
<asp:TextBox ID="txtdistancectv" MaxLength="6" CssClass="textBox_for6tds" runat="server"> </asp:TextBox>
<asp:RegularExpressionValidator ID="revtxtdistancectv" runat="server" Display="Static"
SetFocusOnError="True" ValidationExpression="[0-9]*\.?[0-9]*" ControlToValidate="txtdistancectv"></asp:RegularExpressionValidator></ItemTemplate>
<ItemStyle HorizontalAlign="center" />
</asp:TemplateField>
</Columns>
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
</div>
<asp:ValidationSummary ID="ValidationSummary1" runat="server" HeaderText="You must enter the Numeric Value:"
ShowMessageBox="True" ShowSummary="False" Style="position: static" />