protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.erdWidget.RetrieveingData += new RetrieveingGridDataEvent(erdWidget_RetrieveingData);
erdWidget.BindGrid();
BindDataToCheckBox(State.MaintainFavWidget.FavWidgetListResultUpdate);
}
}
页面回传的时候
#region refresh the grid
protected void radAjaxManageOne_AjaxRequest(object sender, AjaxRequestEventArgs e)
{
if (e.Argument == "Rebind")
{
erdWidget.MasterTableView.SortExpressions.Clear();
erdWidget.MasterTableView.GroupByExpressions.Clear();
erdWidget.RetrieveingData += new RetrieveingGridDataEvent(erdWidget_RetrieveingDataTwo);
erdWidget.BindGrid();
}
else if (e.Argument == "RebindAndNavigate")
{
erdWidget.MasterTableView.SortExpressions.Clear();
erdWidget.MasterTableView.GroupByExpressions.Clear();
erdWidget.MasterTableView.CurrentPageIndex = erdWidget.MasterTableView.PageCount - 1;
erdWidget.Rebind();
}
}
#endregion
#region bind data to grid after update op
protected IEnumerable erdWidget_RetrieveingDataTwo(object source, Framework.Controls.ExtendedRadGridRetrieveingDataArgs args)
{
BindDataToCheckBox(State.MaintainFavWidget.FavWidgetListResultUpdate);
return State.MaintainFavWidget.FavWidgetListResultUpdate;
}
#endregion
checkbox数据绑定和onchanged事件
#region bind data to checkbox
protected void BindDataToCheckBox(IEnumerable<WidgetEntity> widgetEt)
{
int i = 0;
foreach (GridDataItem dataItem in erdWidget.MasterTableView.Items)
{
if(widgetEt.Count()>0)
{
(dataItem.FindControl("cbFavWidget") as CheckBox).Checked = widgetEt.ToList()[i].FavWidget;
}
++i;
}
}
protected void WidgetRowSelection(object sender, EventArgs e)
{
((sender as CheckBox).NamingContainer as GridItem).Selected = (sender as CheckBox).Checked;
}
#endregion
现在时页面回传的时候 protected void BindDataToCheckBox(IEnumerable<WidgetEntity> widgetEt)这个数据绑定函数要执行。但是不执行OnCheckedChanged事件。在grid控件中得checkbox全部变为false了???
这个需要Checkbox的唯一ID,你可以去grid行号来作为checkbox的ID
Parser Error Message: The server tag is not well formed.
Source Error:
Line 68: <HeaderTemplate>Favorite Widget</HeaderTemplate>Line 69: <ItemTemplate>Line 70: <asp:CheckBox id ="<%# Eval("UserId") %>" AutoPostBack="True" runat="server" OnCheckedChanged="WidgetRowSelection"></asp:CheckBox>Line 71: </ItemTemplate>Line 72: </telerik:GridTemplateColumn>
|
我这些把标签的id赋值好像不满足条件的