Gridview Pageindexchanging事件疑问 [英] Gridview Pageindexchanging event doubt
问题描述
场景
- 我有一个下拉
- 选择更改的下拉事件...网格填充。 ...允许分页成为现实
- 当我导航到第二页时我收到错误
Microsoft Jscript运行时错误:
system.webform.pagerequestmanagerservererrorexception:
gridview'GridzeroApprovedKm'触发了未处理的事件PageIndexChanging。
-------------------------------------------- --- aspx页面------------------------------
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">
-------------------代码背后 - 填充GridView -------------------- ---------
- 网格人物
-------------------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();
}
---------- ------------ GridView的PageIndexChange事件处理程序----------------
----------------------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();
}
再次我试图通过写作来填充网格上面的代码。
我在哪里做错了?
---我的理解是<当我导航到下一页时,
。下拉列表中有选择但没有在第一页中选择的值。
- 这可能是它不工作的原因
- 如果这是问题....那么当我导航到下一页....应该选择下拉,因为它在第一页被选中。 .so选择的更改事件将触发并且网格将填充
- 如果我错了,请纠正我
- 也请告诉我如何解决这个问题
- 这是我的页面加载事件
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
{
}
}
- 我在aspx页面使用的更新面板
--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" />
推荐答案
onpageindexchanging=\"GridZeroApprovedKm_PageIndexChanging\"
replace this Code with this
OnPageIndexChanging = \"GridZeroApprovedKm_PageIndexChanging\"
onpageindexchanging="GridZeroApprovedKm_PageIndexChanging"
replace this Code with this
OnPageIndexChanging = "GridZeroApprovedKm_PageIndexChanging"
--Sorry guys
onpageindexchanging=\"GridZeroApprovedKm_PageIndexChanging\"
this is working
----------------------------
But when i clean and build again.....now its working...
--Sorry guys
onpageindexchanging="GridZeroApprovedKm_PageIndexChanging"
this is working
----------------------------
But when i clean and build again.....now its working...
这篇关于Gridview Pageindexchanging事件疑问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!