asp.net中DataList的学习
来源:互联网 发布:手机nfc读卡器软件 编辑:程序博客网 时间:2024/06/01 09:14
前端:
<asp:DataList ID="dl_ej" runat="server" RepeatDirection="Horizontal" RepeatColumns="1" OnItemDataBound="dl_ej_DataBinding" HorizontalAlign="Left" >
<ItemTemplate>
<a class=p10 href="second.aspx?menu_id=<%#Eval("Menu_ID")%>" target="_blank"><%#Eval("Menu_Name")%></a>
<span>[<asp:Label ID="lblRecordCount" runat="server"></asp:Label>]</span><asp:Label ID="Label1" runat="server" CssClass="cClass" ></asp:Label>
</ItemTemplate>
</asp:DataList>
后端:
Label Label1 = (Label)e.Item.FindControl("Label1");
Label lblRecordCount = (Label)e.Item.FindControl("lblRecordCount");
string strSQL = "select * from Class where Menu_ParentLevel=" + this.dl_ej.DataKeys[e.Item.ItemIndex].ToString() + " and Menu_Lock=0 order by Menu_ID asc";
IDataReader dr = Class1.GetDataReader(strSQL);
SqlConnection con = Class1.DBconnection();
while (dr.Read())
{
string sql = "select * from wj_User where C_Three='" + dr["Menu_ID"] + "'";
SqlDataAdapter da1 = new SqlDataAdapter(sql, con);
DataSet ds1 = new DataSet();
da1.Fill(ds1, "Product");
string rows = ds1.Tables["Product"].Rows.Count.ToString();
Label1.Text += " <a class=p11 href='second.aspx?menu_id=" + dr["Menu_ParentLevel"] + "&subid=" + dr["Menu_ID"] + "' target=_blank>" + dr["Menu_Name"].ToString() + " [" + rows + "]</a><span class='font_1'></span> ";
da1.Dispose();
ds1.Dispose();
}
string sqlStr = "select * from wj_User where C_Two='" + this.dl_ej.DataKeys[e.Item.ItemIndex].ToString() + "'";
SqlDataAdapter da = new SqlDataAdapter(sqlStr, con);
DataSet ds = new DataSet();
da.Fill(ds, "Product");
string num = ds.Tables["Product"].Rows.Count.ToString();
lblRecordCount.Text = num;
da.Dispose();
ds.Dispose();
con.Close();
con.Dispose();
效果如下:
- asp.net中DataList的学习
- ASP.NET学习:DataList的使用
- ASP.NET学习:DataList的使用
- asp.net中DataList的用法
- Asp.net DataList嵌套DataList的实现
- ASP.NET中DataList控件
- Asp.NET中DataList 用法
- [我的ASP.net学习历程]DataList(DataBind)(1)
- [我的ASP.net学习历程]DataList(DataBind)(2)
- ASP.NET 2.0 中对DataList,DatGrid,Repeater的小议
- ASP.NET 中DataList控件的分页实现
- ASP.NET中DataList自定义的按钮触发事件
- asp.net中Datalist使用数字分页的实现方法
- ASP.NET中gridview、datalist、repeater、FormView、DetailsView的区别
- asp.net 获取Datalist中Checkbox的值
- .NET中DataList嵌套DataList的实例
- asp.net学习之DataList控件
- ASP.NET中DataList分页功能
- JavaScript 语言精粹的笔记
- 流年的最新伤感日志:年轻的时候,会轻狂
- 系统调用和c库之间的关系
- [ java ] java基础io流!
- 黑马程序员--06 JAVA的面向对象思想与二维数组
- asp.net中DataList的学习
- 唉,笨
- Struts2中启用各个内置对象的方法
- 质因数分解算法
- 许多事情,总是在经历过后才懂得
- 方法论、方法论——程序员的阿喀琉斯之踵
- 寻找21位或者更多位的水仙花数
- Android 获得图片的总结
- 黑马程序员_银行业务调度系统