I am dynamically generating the radgrid at runtime (coz number of columsn will be known only at runtime). I am adding a GridButtonColumn for each column as below (where * is the GridButtonColumn..which will be an ImageButton, ValueA1, ValueB1, etc are Textbox in ItemTemplate)
Name A B
Test1 valueA1 * valueB1 *
Test2 valueA2 * valueB2 *
Test3 valueA3 * valueB3 *
Bulk Update Textbox1 * Textbox2 *
The code for it is as below,
btnColOk = new GridButtonColumn();
btnColOk.ButtonType =
GridButtonColumnType.ImageButton;
rgTest.MasterTableView.Columns.Add(btnColOk);
btnColOk.ImageUrl =
@"~\Images\tick.png";
btnColOk.CommandName =
"btnColOk_Click";
Now in the ItemCommand Event, the code is as below,
protected
void rgTest_ItemCommand(object source, GridCommandEventArgs e)
{
if (e.CommandName == "btnColOk_Click")
{
GridDataItem dataItem = (GridDataItem)e.Item;
ImageButton btn1 = (ImageButton)dataItem["btnColOk"].Controls[0];
btn1.Click +=
new ImageClickEventHandler(btn1_Click);
}
}
Now when i click on any ImageButtons, am getting an error as
"An error has occurred because a control with id 'rgTest$ctl00$ctl04$ctl00' could not be located or a different control is assigned to the same ID after postback. If the ID is not assigned, explicitly set the ID property of controls that raise postback events to avoid this error. "
But am not able to specify an id for 'btnColOk' GridButtonColumn.
Can anyone please help me in this?
Thanks
Sujith