Where are the DataValueField values for a CheckBoxList stored?

前端 未结 10 2090
旧时难觅i
旧时难觅i 2020-12-16 06:42

I have this CheckBoxList on a page:



        
10条回答
  •  鱼传尺愫
    2020-12-16 07:17

    Easy Way I Do It.
    
    //First create query directly From Database that contains hidden field code format (i do it in stored procedure)
    
    SELECT Id,Name + '' as Name FROM User
    
    //Then bind checkbox list as normally(i bind it from dataview).
    
    cbl.DataSource = dv;
    cbl.DataTextField = "Name";
    cbl.DataValueField = "Id";
    cbl.DataBind();
    
    //Then finally it represent code as follow.
    
    
    This way you can get DataValueField as inside hiddenfield and also can get it value from client side using javascript.

提交回复
热议问题