I have followed the code snippets from other posts on this issue to add a linkbutton to the group headers of my radgrid but on clicking the linkbutton's I get an object not specified error.
I'm adding the following code, where item is the gridgroupheaderitem and then handling the command in the radgrid_itemcommand event.
the code is added in both the radgrid_itemcreated and radgrid_itemdatabound events.
I'm adding the following code, where item is the gridgroupheaderitem and then handling the command in the radgrid_itemcommand event.
the code is added in both the radgrid_itemcreated and radgrid_itemdatabound events.
protected void RadGrid2_ItemDataBound(object sender, GridItemEventArgs e)
{
if (e.Item is GridGroupHeaderItem)
{
createbutton((GridGroupHeaderItem)e.Item);
}
}
protected void createbutton(GridGroupHeaderItem header)
{
if (header.DataCell.FindControl("thisGroup") == null)
{
Label mylab = new Label();
mylab.ID = "thisNumber";
DataRowView drv = header.DataItem as DataRowView;
mylab.Text = drv["Location"].ToString();
Label mylabno = new Label();
mylab.ID = "thisGroup";
mylabno.Text = drv["GroupOrder"].ToString();
mylabno.Visible = false;
GridGroupHeaderItem item = header as GridGroupHeaderItem;
LinkButton lnk = new LinkButton();
lnk.Text = "Move up ";
lnk.Style.Add("margin", "3px");
LinkButton xnk = new LinkButton();
xnk.Text = "Move down";
xnk.Style.Add("margin", "2px");
xnk.Style.Add("padding", "2px");
item.DataCell.Controls.Add(mylab);
item.DataCell.Controls.Add(mylabno);
lnk.CommandName = "Up";
item.DataCell.Controls.Add(lnk);
xnk.CommandName = "Down";
item.DataCell.Controls.Add(xnk);
}
}
I'm guessing its related to the fact this radgrid is ajaxified, but not entirely sure. any ideas??