To get text of Button Field column in GridView
:)Hello,
I have designed a GridView with two columns. One is ButtonField type which is bound with "Customer_Name" field and second BoundColumn type with "Company" field.
I want to store text of cell of ButtonField column of any row. My code is as below.
private void CustomersGridView_RowCommand(Object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Select")
{
int index = Convert.ToInt32(e.CommandArgument);
GridViewRow selectedRow = CustomersGridView.Rows[index];
string strValue = selectedRow.Cells[1].Text;
Response.Write(strValue);
//As above line returns the text of column 2. Here I want to return text of column 1. How?????
}
}
Please give me the solution. Thanks.:)
|