Hello,
I am trying to access a cell value on post back when ever the user will click command button (select) in RadGrid. I have a command button with name select and this is what I am doing in code behind:
protected void leadsGrid_ItemCommand(object sender, GridCommandEventArgs e)
{
GridDataItem myDataItem = (GridDataItem)leadsGrid.SelectedItems[0].DataItem;
Response.Write(myDataItem["lead_name"].Text);
}
but whenever I click on select button it gives me
Index was out of range. Must be non-negative and less than the size of the collection.
I supposed its occurring because SelectedItems[0] does not have anything but I don't know why it does not have anything as pressing the select command should select the row ?
Please tell me what I am doing wrong ? or a correct way to access cell values of selected row. I am not working on multiple rows so I only want to access cell values of one select row. I have experience with normal ASP.net GridView but I am fairly new with RadGrid so I apologize if this is a basic question.
Thanks.
I am trying to access a cell value on post back when ever the user will click command button (select) in RadGrid. I have a command button with name select and this is what I am doing in code behind:
protected void leadsGrid_ItemCommand(object sender, GridCommandEventArgs e)
{
GridDataItem myDataItem = (GridDataItem)leadsGrid.SelectedItems[0].DataItem;
Response.Write(myDataItem["lead_name"].Text);
}
but whenever I click on select button it gives me
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
I supposed its occurring because SelectedItems[0] does not have anything but I don't know why it does not have anything as pressing the select command should select the row ?
Please tell me what I am doing wrong ? or a correct way to access cell values of selected row. I am not working on multiple rows so I only want to access cell values of one select row. I have experience with normal ASP.net GridView but I am fairly new with RadGrid so I apologize if this is a basic question.
Thanks.