Quantcast
Channel: Web Forms
Viewing all articles
Browse latest Browse all 23244

Set Gridview Checkbox in DataRowBound.....

$
0
0

I have a GridView with a CheckBox, how do I set the Checkbox to true or false based on the DataItem Value....?

 protected void gvName_RowDataBound(object sender, GridViewRowEventArgs e)
 {
      System.Data.DataRowView drv;
      drv = (System.Data.DataRowView)e.Row.DataItem;

     if (e.Row.RowType == DataControlRowType.DataRow)
     {
         CheckBox chkActive = (CheckBox)e.Row.FindControl("chkActive");
         
    if (DataRow["Active"] == true)    <--- Not sure if this is correct....
        {
          chkActive.Checked = true;    <--- How do I find the DataItem and set control to true?
          lblCreatedBy.Text = e.Row.DataItem["CreatedBy"];        <--- Same here need the DataItem...? 

        }
     }
 }


Viewing all articles
Browse latest Browse all 23244

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>