在每个复选框中使用复选框列表检查其子类别必须绑定到另一个复选框 [英] using check box list in each checkbox checked its sub category has to bind in another checkbox

查看:52
本文介绍了在每个复选框中使用复选框列表检查其子类别必须绑定到另一个复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有类别和子类别表,
在类别表中包含所有类别,而在子类别表中包含每个类别的所有子类别.
这些以主"形式输入.

我有一个Web表单,其中必须将所有类别绑定到一个复选框中,
当每个类别复选框选中,我需要结合其各自的子类别中另一个复选框列表.同样,我必须将每个类别中的所有子类别都绑定为true.

保存时,我必须保存所有子类别和类别.但是我有一个问题,如何识别该子类别属于哪个类别.

I have category and subcategory tables,
In category tables consist of all categories and whereas in sub category table consist of all subcategory of each category.
These are entered in Master form.

I have web form in which I have to bind all categories in a check boxes,
when each category check box checked I need to bind its respective subcategories in another check box list. same way I have to bind all Subcategories in each category checked true.

While saving I have to save all subcategories and categories . But I have a problem that how I can identify this subcategory belongs to which category.

推荐答案

首先,您需要具有一些类才能将类别集合存储在树中.

例如:
First, you need to have some class to store your category collection in tree.

For example:
public class CategoryBO
{
 public int CategoryID{get;set;}
 public List<CategoryBO> SubCategories{get;set;}
}




or

public class CategoryBO
{
 public int CategoryID{get;set;}
 public int? ParentCategoryID{get;set;}
}



然后,您应该实现某种方法来将复选框列表或树视图(带有复选框)绑定到某个控件中,在该控件中,您将保存有关类别的必需信息(使用ParentCategoryID标识父级的fe).



Then you should implement some method to bind checkboxlist or treeview (with checkboxes) into some control in which you will save required information about category (f.e. with ParentCategoryID to identify parent).


一个如果您使用CheckBoxLists,则方法是将路径存储在每个ListItem中的Value中,然后读取此信息以标识父级.
看起来像这样^

One of the way if you are using CheckBoxLists is to store path in Value in every ListItem and then read this information to identify parents.
It looks like this^

<asp:checkboxlist id="Parents" runat="server" >
<asp:listitem text="Employees" value="1">
<asp:listitem text="Unemployees" value="2">

        
<asp:checkboxlist id="Childs" runat="server" >
<asp:listitem text="Company1 Employees" value="1/1">  
<asp:listitem text="Company2 Employees" value="1/2">

        
<asp:checkboxlist id="Company1Employees" runat="server" >
<asp:listitem text="Peter" value="1/1/1">
<asp:listitem text="Pavel" value="1/1/2">



如果有帮助,请投票给我.



If it will help you please vote my answer.


这篇关于在每个复选框中使用复选框列表检查其子类别必须绑定到另一个复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆