Hi,
I am trying to do both Alpha filtering and the "edit" link that show a modal window. Both are set up using
RadGrid2_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e). One uses e.Item is GridCommandItem (the alpha filter) and the other uses e.Item is GridDataItem.
I think each get set up OK at the outset, because I can see the alpha characters and the hyperlink around the "edit". But the only one that works is the "edit", meaning that it pops up the modal window. The alpha filtering fails and says "sys.WebForms.PageRequestManagerServerErrorException: Index was out of range. Must be non-negative and less than the size of the collection."
Here is the code:
public void RadGrid2_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
if (e.Item is GridCommandItem)
{
lblMessage.Text = "GridCommandItem";
GridCommandItem commandItem = (e.Item as GridCommandItem);
PlaceHolder container = (PlaceHolder)commandItem.FindControl("PlaceHolder1");
for (int i = 65; i <= 65 + 25; i++)
{
LinkButton linkButton1 = new LinkButton();
LiteralControl lc = new LiteralControl(" | ");
linkButton1.Text = "" + (char)i;
linkButton1.CommandName = "alpha";
linkButton1.CommandArgument = "" + (char)i;
container.Controls.Add(linkButton1);
container.Controls.Add(lc);
}
LiteralControl lcLast = new LiteralControl(" ");
container.Controls.Add(lcLast);
LinkButton linkButtonAll = new LinkButton();
linkButtonAll.Text = "All";
linkButtonAll.CommandName = "NoFilter";
container.Controls.Add(linkButtonAll);
}
if (e.Item is GridDataItem)
{
lblMessage.Text = "GridDataItem";
HyperLink editLink = (HyperLink)e.Item.FindControl("EditLink");
editLink.Attributes["href"] = "#";
editLink.Attributes["onclick"] = String.Format("return ShowEditForm('{0}','{1}');", e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["idAssociate"], e.Item.ItemIndex);
}
}
Can anyone tell me what I am doing wrong?
Thanks,
Kevin Long
I am trying to do both Alpha filtering and the "edit" link that show a modal window. Both are set up using
RadGrid2_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e). One uses e.Item is GridCommandItem (the alpha filter) and the other uses e.Item is GridDataItem.
I think each get set up OK at the outset, because I can see the alpha characters and the hyperlink around the "edit". But the only one that works is the "edit", meaning that it pops up the modal window. The alpha filtering fails and says "sys.WebForms.PageRequestManagerServerErrorException: Index was out of range. Must be non-negative and less than the size of the collection."
Here is the code:
public void RadGrid2_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
if (e.Item is GridCommandItem)
{
lblMessage.Text = "GridCommandItem";
GridCommandItem commandItem = (e.Item as GridCommandItem);
PlaceHolder container = (PlaceHolder)commandItem.FindControl("PlaceHolder1");
for (int i = 65; i <= 65 + 25; i++)
{
LinkButton linkButton1 = new LinkButton();
LiteralControl lc = new LiteralControl(" | ");
linkButton1.Text = "" + (char)i;
linkButton1.CommandName = "alpha";
linkButton1.CommandArgument = "" + (char)i;
container.Controls.Add(linkButton1);
container.Controls.Add(lc);
}
LiteralControl lcLast = new LiteralControl(" ");
container.Controls.Add(lcLast);
LinkButton linkButtonAll = new LinkButton();
linkButtonAll.Text = "All";
linkButtonAll.CommandName = "NoFilter";
container.Controls.Add(linkButtonAll);
}
if (e.Item is GridDataItem)
{
lblMessage.Text = "GridDataItem";
HyperLink editLink = (HyperLink)e.Item.FindControl("EditLink");
editLink.Attributes["href"] = "#";
editLink.Attributes["onclick"] = String.Format("return ShowEditForm('{0}','{1}');", e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["idAssociate"], e.Item.ItemIndex);
}
}
Can anyone tell me what I am doing wrong?
Thanks,
Kevin Long