in my application i am trying to get the checkbox which is in the gridview i use the foreach control but it is shoing null this is my code./..
source
‘>
‘ Visible =”false” >
‘>
‘ TextMode=”multiLine” >
‘>
‘ TextMode=”multiLine” >
‘>
‘ />
public void getPlaylist()//i write the finding control in a method
{
MyplalistBL clsMyplalstBl=new MyplalistBL ();
clsMyplalstBl.Userid = Session[“userid”].ToString();
DataSet ds = clsMyplalstBl.getPlaylistBl();
if (ds.Tables[0].Rows.Count > 0)
{
grdplaylist .DataSource =ds.Tables [0];
grdplaylist.DataBind();
foreach (GridViewRow gr in grdplaylist.Rows)
{
CheckBox ch = (CheckBox)gr.FindControl("chksett");
string s = ds.Tables[0].Rows[0]["settings"].ToString();
if (s == "P")
{
ch.Checked = true;
}
else if (s == "PV")
{
ch.Checked = false;
}
}
}
else
{
grdplaylist.DataSource = null;
grdplaylist.DataBind();
}
}
Well, this is interesting…
It looks that you want to load your check box status from database,
so, what you should do is, shift your code to grid view’s databound event and it would start working