0

Hello people, i need your help here. i have a gridview with three fields: Id,Condition and Status.
Under condition i have only two types of data stored - 'Approved' and 'Notapproved' and under status i have checkboxes.
i want: while the page loads, there will be a loop on the gridview rows such that
if the field "Condition" (from database) has the word "approved" then the checkbox of the gridview row will be checked else it will not be checked. please help. here is the code. Also tell me how to update it.

protected void Page_Load(object sender, EventArgs e)
    {
        foreach (GridViewRow gr in GridView1.Rows)

        {
            //if the field "Condition" (from database) has the word "approved"
            //then the checkbox of the gridview row will be checked else  
           //it will not be checked
            
            }
        }
2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by nakor77
0

First if the column in the database only takes two values, one that indicates true and one that indicates false then you should really be using bit for the data type. 1 would be approved and 0 would be unapproved. Then you're gridview would automatically use a checkbox field for that column and you could save yourself extra work. However if that's not going to be something you can change then you're probably going to want to look into using the GridView's RowDataBound event to do this.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.