Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Get Cell value + GridView + ASP

I bound gridview with databse..property Checkbox -true .
I have three columns roll,name ,roll.

I want to get the cell value of second column whose corresponding checkboxes are checked...

on Button1_Click, in varable bchecked,checkboxes status are coming..I want to get the cell value..Plz help me out..

SOURCE TAB
[code]



























[/code]

[code]
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack
{

query = "Select * from Information";
conn.Open();
cmd = new SqlCommand(query, conn);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
conn.Close();
}
}



[code]

protected void Button1_Click(object sender, EventArgs e)
{
string sName;
bool bchecked;

for (int i = 0; i < this.GridView1.Rows.Count; i++)
{
bchecked = ((CheckBox)GridView1.Rows[i].FindControl("chk")).Checked;
if (bchecked == true)
{
Label lblName = (Label)GridView1.FindControl("Name") ;
sName = lblName.ToString ;

}


}


}
[/code]
Sign In or Register to comment.