0
我在我的頁面上有Telerik
RadGrid
和DropDownList
。我想在從DropDownList中選擇任何值時更改RadGrid的數據源。我可以執行所有代碼段,但數據源和數據永遠不會改變。以下是代碼:在DropDownList更改事件更改Telerik 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(的DropDownList):
<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
@sakir我也試過 ,但行爲是一樣的。 –
rizzz86