码迷,mamicode.com
首页 > 其他好文 > 详细

读取datalist中的数据

时间:2015-02-14 01:19:35      阅读:183      评论:0      收藏:0      [点我收藏+]

标签:datalist

//前台: 
<asp:DataList ID="daliXi" runat="server" Width="100%" RepeatDirection="Horizontal"> 
                                                    <ItemTemplate> 
                                                    <asp:CheckBox ID="cbXi" runat="server" />   
                                                    <asp:Label ID="lbXi" runat="server" Text=’ <%#DataBinder.Eval(Container.DataItem,"Stu_xbmc") %>’></asp:Label> 
                                                    </ItemTemplate> 
                                                </asp:DataList> 
//后台: 
for (int i = 0; i <= daliXi.Items.Count-1; i++) 
                    {. 
                        CheckBox cb=(CheckBox)daliXi.Items[i].FindControl("cbXi");(cb指向”cbXi”的内存地址,修改cb的属性,即修改cbXi) 
                         if (cb.Checked) 
                         { 
                             Label lb = (Label)daliXi.Items[i].FindControl("lbXi"); 
                             Response.Write("<script type="text/javascript">alert(‘"+lb.Text+"‘)</:script>"); 
                             cb.Checked=false; 
                         } 
                }

读取datalist中的数据

标签:datalist

原文地址:http://9622637.blog.51cto.com/9612637/1614314

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!