本文介绍了复选框列表和选中的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 以下是我的代码 < osm:SlideMenu ID = SlideMenu1 SelectedId = true runat = server AllExpanded = True > < MenuItems > < osm:Parent > 类别< / osm:Parent > < osm:孩子 > < asp:CheckBoxList ID = cblCategory runat = server > < / asp:CheckBoxList > < asp:按钮 ID = btnCategory runat = server 文本 = 提交 onclick = btnCategory_Click / > < / osm:Child > < / MenuItems > < / osm:SlideMenu > 类别 男孩顶部穿上 纱丽 - 复选框 衬衫 - 复选框 毛衣&运动衫 - 复选框 T恤 - 复选框 现在我的问题是,当选中任何复选框并点击按钮时,它会显示选中的类别,我该怎么办解决方案 protected void btnCategory_Click(object sender,System.Web.UI.ImageClickEventArgs e) { for(int i = 0; i< cblCategory.Items.Count; i ++) { if(cblCategory.Items [i] .Selected) { Response.Write(SelectedCategory:+ cblCategory.Items [i] .Text); } } } 如果不起作用,请尝试使用''findcontrol' Following is my code<osm:SlideMenu ID="SlideMenu1" SelectedId="true" runat="server" AllExpanded="True"> <MenuItems> <osm:Parent>Category</osm:Parent> <osm:Child> <asp:CheckBoxList ID="cblCategory" runat="server"> </asp:CheckBoxList> <asp:Button ID="btnCategory" runat="server" Text="Submit" onclick="btnCategory_Click" /> </osm:Child> </MenuItems> </osm:SlideMenu>CategoryBoys Top WearSarees-CheckboxShirts-checkboxSweaters & Sweatshirts-checkboxT Shirts-checkboxNow my problem is that when check in any checkbox and click on button it display checked category so how can i do it 解决方案 protected void btnCategory_Click(object sender, System.Web.UI.ImageClickEventArgs e){ for (int i = 0; i < cblCategory.Items.Count; i++) { if (cblCategory.Items[i].Selected) { Response.Write("SelectedCategory:" + cblCategory.Items[i].Text ); } }}and if it doesnot works then try using ''findcontrol'' 这篇关于复选框列表和选中的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-30 18:23