repeater里用户控件绑定数据库的值(记住区分Page_Init和Page_Load)
2012-09-26 11:31
405 查看
<tr> <td><%=this.FunctionName %></td> <td> <input id="chk_<%=this.ClientID %>" type="checkbox" onclick="ckall(this,'fun_<%=this.ClientID %>')"/>全选 <span id="fun_<%=this.ClientID %>"> <asp:CheckBox ID="ckinsert" runat="server" Text="新增"/> <asp:CheckBox ID="ckedit" runat="server" Text="编辑"/> <asp:CheckBox ID="ckdelete" runat="server" Text="删除"/> <asp:CheckBox ID="ckview" runat="server" Text="查看"/> <asp:CheckBox ID="ckexecute" runat="server" Text="执行" /> <asp:CheckBox ID="cklist" runat="server" Text="列表"/> <asp:CheckBox ID="ckprint" runat="server" Text="打印" /> </span> </td> </tr>
public partial class SuperRoles_Power_Detail : System.Web.UI.UserControl { private string functionID; /// <summary> /// 功能ID /// </summary> public string FunctionID { get { return functionID; } set { functionID = value; } } private string functionName; /// <summary> /// 功能名称 /// </summary> public string FunctionName { get { return functionName; } set { functionName = value; } } /// <summary> /// 新增 /// </summary> public bool IsInsert { get { return this.ckinsert.Checked; } set { this.ckinsert.Checked = value; } } /// <summary> /// 编辑 /// </summary> public bool IsEdit { get { return this.ckedit.Checked; } set { this.ckedit.Checked = value; } } /// <summary> /// 删除 /// </summary> public bool IsDelete { get { return this.ckdelete.Checked; } set { this.ckdelete.Checked = value; } } /// <summary> /// 查看 /// </summary> public bool IsView { get { return this.ckview.Checked; } set { this.ckview.Checked = value; } } /// <summary> /// 执行 /// </summary> public bool IsExecute { get { return this.ckexecute.Checked; } set { this.ckexecute.Checked = value; } } /// <summary> /// 列表 /// </summary> public bool IsList { get { return this.cklist.Checked; } set { this.cklist.Checked = value; } } /// <summary> /// 打印 /// </summary> public bool IsPrint { get { return this.ckprint.Checked; } set { this.ckprint.Checked = value; } } protected void Page_Load(object sender, EventArgs e) { }
WebUserControl.SuperRoles_Power_Detail detail = (WebUserControl.SuperRoles_Power_Detail)item1.FindControl("SuperRoles_Power_Detail1"); Guid FunctionID = Guid.Parse(detail.FunctionID); string functionChecked = string.Empty; if (detail.IsInsert) functionChecked += SuperRoles.Enum.Command.Insert + ","; if (detail.IsEdit) functionChecked += SuperRoles.Enum.Command.Edit + ","; if (detail.IsDelete) functionChecked += SuperRoles.Enum.Command.Delete + ","; if (detail.IsView) functionChecked += SuperRoles.Enum.Command.View + ","; if (detail.IsExecute) functionChecked += SuperRoles.Enum.Command.Execute + ","; if (detail.IsList) functionChecked += SuperRoles.Enum.Command.List + ","; if (detail.IsPrint) functionChecked += SuperRoles.Enum.Command.Print + ","; if (functionChecked == string.Empty) continue; functionChecked = functionChecked.TrimEnd(',');
protected void Rep_BoundFunction(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { DataRowView rowv = (DataRowView)e.Item.DataItem;//找到分类Repeater关联的数据项 WebUserControl.SuperRoles_Power_Detail detail = (WebUserControl.SuperRoles_Power_Detail)e.Item.FindControl("SuperRoles_Power_Detail1"); if (rowv != null) { detail.FunctionID = rowv["ID"].ToString(); detail.FunctionName = rowv["Title"].ToString(); } } }
<asp:Repeater ID="Rep_SystemFunction" runat="server" OnItemDataBound="Rep_BoundFunction"> <ItemTemplate> <uc_Function:SuperRoles_Power_Detail ID="SuperRoles_Power_Detail1" runat="server"/> </ItemTemplate> </asp:Repeater>
相关文章推荐
- 将数据库的值绑定到Repeater控件里面
- 在Pageload方法里绑定DropDownLis等控件传不出值的问题
- 地磅称量系统之(37~39) 直接向数据库的数据表WtBill添加测试数据以及绑定用户控件和使用编码的方式控制dataGridView控件的每列属性和添加数据数据库的表中不存在的字段(非绑定列)
- 在Pageload方法里绑定DropDownLis等控件传不出值的问题
- 从数据库中,绑定JQuery Accordion控件---Repeater control
- CascadingDropDown从数据库中读取数据绑定到DropDownList控件上
- C#之Winform中treeview控件绑定数据库
- jQuery+ajax从数据库取值和和绑定前台html控件上,然后再通过ajax把值传到后台,让后台写入到数据库
- 发布一个OutlookBar控件,支持数据库绑定(完全开源)
- XmlDataSource控件绑定asp:Repeater
- 枚举 控件的绑定及数据库读取转换
- Oracle 11g 新特性数据库用户密码区分大小写参数sec_case_sensitive_logon对sys无效
- Repeater绑定事件ItemDataBound中获取数据库中数据
- Repeater控件自定义数据源代码绑定实例
- 将Page——Load放到OnInit事件中执行
- 数据库绑定控件
- 2009-03-20技术学习:Wicket+iBATIS 实现树控件的数据库绑定
- GridView 后台排列 Column 、 用户自定义GridView 显示、GridView的PreRender ,Init,Load 方法
- 页面(Page)加载用户控件(UserControl)的事件触发顺序
- 一个小提醒:不要在用户控件或者组件使用PAGE对象