Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > how to check/Uncheck a checkbox dynamically in a datagrid in

Thread Tools

how to check/Uncheck a checkbox dynamically in a datagrid in

Posts: n/a
HI all,

I have an issue with check box in datagrid.
I would like it to check and uncheck based on a database value of NULL
or a Date Value.

If there is a date value for that column then check the check box in

If the value is null then keep it unchanged as (Unchecked)

this is in

Your help is appreciated

Thank you


Reply With Quote
Posts: n/a

Datagrid code with check box and date field

<aspataGrid id="grdAuthors" runat="server" Width="626px">
<asp:CheckBox ID="chkbox" Runat="server"></asp:CheckBox>
<asp:BoundColumn DataField="Date" HeaderText="Date"


and with dataItemBound event of grid u can write code as below

string _lblDate = e.Item.Cells[1].Text.ToString(); //date column
CheckBox _chkBox = (CheckBox)e.Item.FindControl("chkbox");
if(_chkBox != null)
if(_lblDate == "True")//Here u can check if some date text is
//bound with the label
_chkBox.Checked = true;

Reply With Quote
subashini subashini is offline
Junior Member
Join Date: Mar 2012
Posts: 6


Try this... it vl help u.
i used gridview.
got the id of the student.
as the userid is in a datalist. so i too from ther.
check the active status from a table.
i used checkboxes. if the user is in an active status then boxes should be checked.
protected void dgGrid_RowDataBound(object sender, GridViewRowEventArgs e)
if (e.Row.RowType == DataControlRowType.DataRow ||
e.Row.RowType == DataControlRowType.Separator)
Label lblstudentname = (Label)e.Row.FindControl("lblstudentname");
string studentname = lblstudentname.Text.Trim();
Label lbluserid = (Label)e.Row.FindControl("lbluserid");
string userid = lbluserid.Text.Trim();
DataSet ds1 = comProfile.getAssessmentChar();
DataList dldata = (DataList)e.Row.FindControl("dldata");
for (int i = 0; i < dldata.Items.Count; i++)
Label lblid1 = (Label)dldata.Items[i].FindControl("lblid1");
string lsid = lblid1.Text.Trim();
int lsid1 = Convert.ToInt32(lsid);
CheckBox chkactive = (CheckBox)dldata.Items[i].FindControl("chk1");
DataSet ds = comProfile.getDetails(userid, iyear, lsid);

if(ds.Tables[0].Rows.Count > 0)
chkactive.Checked = true;
chkactive.Checked = false;


Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
DataGrid and embeded Checkbox..How to find if checkbox clicked =?Utf-8?B?RG90TmV0RGV2?= ASP .Net 1 10-06-2006 04:11 PM
Create the checkbox template column dynamically in datagrid NEMA ASP .Net 0 06-05-2006 02:44 PM
Howto bind CheckBox to the datagrid/ Then update the database field when the checkbox is clicked. Joey Pang ASP .Net Datagrid Control 4 06-13-2005 02:29 AM
how to check/Uncheck a checkbox dynamically in a datagrid in asp.n =?Utf-8?B?U2lsZWVzaA==?= ASP .Net 4 12-02-2004 03:25 PM
how to add checkbox in DataGrid control dynamically? J Gopinath ASP .Net Web Controls 0 06-01-2004 09:45 AM