dear friends,

I am stucked with checkbox.

i have a dynamically adding gridview with checkbox column. in which saving all datas in View state. But when page load check box status are lost. How to fix it.

how to check the status of check box in datatable

Ex: chkbox is my check box. I want to attach previous row datas

whil(i<dt.rows.count)
{
chkbox.checked = "";
}

Can you show us the code you have there?
Maybe it would be better to use the code in overriden event OnShow (form`s event).

In datatable, the column for "checkBoxes" is type of boolean, right? If so, only check if value of cell is true, or false, like:

//loop through the rows of dataTable:
foreach(DataRow row in table.Rows)
{
    //lets say your 1st column is for checkBoxes:
    if(Convert.ToBoolean(row[0])==true)
    {
        // value is true
    }
    else
    {
        // value if false
    }
}

The same you can do if you dont have boolean type of the column. If there is numberic (like 0 and 1) check it like I did for the boolean example.

Can you show us the code you have there?
Maybe it would be better to use the code in overriden event OnShow (form`s event).

In datatable, the column for "checkBoxes" is type of boolean, right? If so, only check if value of cell is true, or false, like:

//loop through the rows of dataTable:
foreach(DataRow row in table.Rows)
{
    //lets say your 1st column is for checkBoxes:
    if(Convert.ToBoolean(row[0])==true)
    {
        // value is true
    }
    else
    {
        // value if false
    }
}

The same you can do if you dont have boolean type of the column. If there is numberic (like 0 and 1) check it like I did for the boolean example.

Thanks for the reply. I will surely check it

This article has been dead for over six months. Start a new discussion instead.