Skip to content

Listview checkbox

sharmitha kt

Asked May 15, 2008, 7:17 AM EDT1 answer
Share
LinkedInX

a listview control with checkboxes

how to pass the checked checkbox values in sql query for updation

please help me

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • Niradhip Chakraborty
    0

    U can do one thing. You can use a datagrid and Inside datagrid add your checkbox. So it is work
    same as listview.Even u also can use listview.I will give you code for datagrid.
    The code has two part first part is html part or .aspx part and the last part is codebehind or
    .aspx.vb part.
    Add datagrid and checkbox like following way in html.
    I guess you are taking the checkbox name from a table. say it is employee table and you want all employee name to be displayed as
    checkbox.say column name is emp_vch_Name
    .aspx:

     

     


               
                   
            

                                
                           

                                                                DataKeyField="emp_vch_Name" runat="server" ShowHeader="false" CssClass="TblBorderBlack">
                                   
                                   
                                       
                                           
                                           
                                                                                                Checked='<%# DataBinder.Eval(Container.DataItem," DayEnd")%>'>
                                               
                                               
                        <%# DataBinder.Eval(Container.DataItem,"emp_vch_Name")%>
                                               
                                           
                                           
                                       
                                                                         
                                   
                               
                           

                     

               

     

    .aspx.vb code:


    Now you want to pass the checked checkbox value to database.If it is checked it store the value as 1 if it is not checked it
    store the value as 0.


    Dim blnEmployee As Boolean

    For Each dgrdItem In dgrdDayEnd.Items
                   blnEmployee = False
                   If CType(dgrdItem.FindControl("chkEmployee"), WebControls.CheckBox).Checked = true Then
                        blnEmployee = True
                    End If
                   strSQL = "Write your update query here and pass the value blnEmployee for particular column in the table where you want to store checked or unchecked checkbox value "
                              
                Next

     

     

    Try it first...................

    Still if u have doubt then send me your full code both .aspx code and .aspx.vb code i will try to fix it.

    0