Click here to Skip to main content
15,900,258 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I bind the datatable in gridview in this grid view checkbox also have
 
if any check box is selected then get the cell value of the check box selected row i use some methods but not working 


What I have tried:

 protected void btnUpdate_Click(object sender, EventArgs e)
{
  TextBox TextBox1 = new TextBox();
foreach (GridViewRow gr in GridView1.Rows)
{
bool isChecked = ((CheckBox)gr.FindControl("chkBxSelect")).Checked;
if (isChecked)
{


//first method
string myvalue = GridView1.Rows[1].Cells[1].ToString();


// second method
GridViewRow row = GridView1.SelectedRow;
TextBox1.Text = row.Cells[0].Text;
try
{
// dt1.Rows.Add(Convert.ToString(GridView1.Cells[1].Text), "", "", "", "");

}

catch (Exception ex)
{
continue;
}
}
}
 }
Posted
Updated 8-Aug-17 20:47pm

1 solution

use GridViewRow object

if (isChecked)
               {
                   string value = gr.Cells[1].Text;

               }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900