checkbox in datagrid

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hkarthik
    New Member
    • Jan 2007
    • 34

    checkbox in datagrid

    hi all,

    i have designed my datagrid in such a way that , my datagrid inserts checkbox in each row as i enter new data's into my database. It works neately. Now the problem that i am facing is , i have added one checkbox on the header of the datagrid. When i check this checkbox all the other checkboxes in my datagrid should get selected and when i recheck all the checkboxes in the datagrid should be rechecked.

    For example i can suggest our mail inbox. In that we have an option called "selectall" . When i click this all the mail's in my inbox get selected and when i recheck,it comes back to the normal form.

    Can anybody help me regarding this
  • enreil
    New Member
    • Jan 2007
    • 86

    #2
    See if this thread is of any help.

    In your datagrid's event handler, you'll need to make sure it handles an event from the header row. Alternatively, if you are dynamically inserting checkboxes, you can declare a separate eventhandler for the checkboxes to use.

    I'll be happy to help if you still need more assistance.

    Originally posted by hkarthik
    hi all,

    i have designed my datagrid in such a way that , my datagrid inserts checkbox in each row as i enter new data's into my database. It works neately. Now the problem that i am facing is , i have added one checkbox on the header of the datagrid. When i check this checkbox all the other checkboxes in my datagrid should get selected and when i recheck all the checkboxes in the datagrid should be rechecked.

    For example i can suggest our mail inbox. In that we have an option called "selectall" . When i click this all the mail's in my inbox get selected and when i recheck,it comes back to the normal form.

    Can anybody help me regarding this

    Comment

    • hkarthik
      New Member
      • Jan 2007
      • 34

      #3
      Originally posted by enreil
      See if this thread is of any help.

      In your datagrid's event handler, you'll need to make sure it handles an event from the header row. Alternatively, if you are dynamically inserting checkboxes, you can declare a separate eventhandler for the checkboxes to use.

      I'll be happy to help if you still need more assistance.

      hi enreil,

      I tried but it's not working. I also used a javascript code but it's not working. And more over where do i write that coding because i am not using any checkbox outside my datagrid control. I have a checkbox in the header of my datagrid control so when i check that box all the check boxes inside the datagrid which consists of data should get selected. How to do so

      Comment

      • vinaykeshav
        New Member
        • Dec 2006
        • 25

        #4
        at ur datagrid ItemDataBound event
        if(e.Item.ItemT ype == ListItemType.He ader)

        CheckBox chBox = new CheckBox();
        chBox = (CheckBox)e.Ite m.FindControl(c ontrol name);

        if this is checked then...

        if(e.Item.ItemT ype == ListItemType.It em)

        either loop into all rows or else if possible get the instance of that
        column where checkbox is present and check all the boxes...

        try this .. this is just an thought i got ... hope u can fix ur probs..

        Originally posted by hkarthik
        hi enreil,

        I tried but it's not working. I also used a javascript code but it's not working. And more over where do i write that coding because i am not using any checkbox outside my datagrid control. I have a checkbox in the header of my datagrid control so when i check that box all the check boxes inside the datagrid which consists of data should get selected. How to do so

        Comment

        Working...