【发布时间】:2023-04-10 11:22:16
【问题描述】:
我的页面上有 Telerik RadGrid 和 DropDownList。当从 DropDownList 中选择任何值时,我想更改 RadGrid 的数据源。我可以执行所有代码,但数据源和数据从未改变。以下是代码:
ASPX (RadGrid):
<telerik:RadGrid ID="exceptionList" runat="server" OnNeedDataSource="exceptionList_NeedDataSource" AutoGenerateColumns="False" PageSize="10" EnableEmbeddedSkins="False" AllowPaging = "True" AllowSorting = "True" GridLines="None"
PagerStyle-AlwaysVisible="true" AllowCustomPaging="true"
Width="100%">
ASPX(下拉列表):
<asp:DropDownList id="FormCode" runat="server" CssClass="cmb" style="width:98%;" OnSelectedIndexChanged="FormCode_SelectedIndexChanged" AutoPostBack="true"></asp:DropDownList>
ASPX.CS
所有这些方法都被成功调用和执行,但对 RadGrid 没有影响。
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
LoadComboBox(...);
FormCode.Items[0].Text = "Select an item";
}
}
protected void exceptionList_NeedDataSource(object source, GridNeedDataSourceEventArgs e)
{
DataView gridData = InitData(...);
exceptionList.DataSource = gridData;
exceptionList.PageSize = 50;
}
protected void FormCode_SelectedIndexChanged(object sender, EventArgs e)
{
DataView gridData = ChangeData(...);
exceptionList.DataSource = gridData;
exceptionList.DataBind();
}
【问题讨论】:
-
你为什么不使用
-
@sakir 我也试过
但行为是一样的。
标签: asp.net drop-down-menu telerik radgrid