andy12279
asked on
get cell value from gridview with row index
I am trying to get the specific cell value from my GridView in the RowDataBound method.
But I am getting an error. Please help?
But I am getting an error. Please help?
protected void gvDisposition_RowDataBound(object sender, GridViewrowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
HyperLink editLink = (HyperLink)e.Row.FindControl("DispositionView");
editLink.Attributes["href"] = "#";
int index = e.Row.RowIndex ;
GridViewrow row = gvDisposition.SelectedRow[index]; //get error with index is Zero
string cellvalue = row.Cells[6].Text;
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks guys. Both of your answers helped solve my problem .
its better try some different method .. like deleting, selection, Editing etc
giving you example on editing event
<asp:GridView ID="MyDataGrid" runat="server" AutoGenerateColumns="false
and on codebehind file use this
public void MyDataGrid_EditCommand(obj
{
MyDataGrid.EditItemIndex = e.Item.ItemIndex;
BindData(); // this method for rebind your grid
}