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
            
            }
        }

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.