This is a migrated thread and some comments may be shown as answers.

e.Item is GridCommandItem and e.Item is GridDataItem

1 Answer 173 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kevin
Top achievements
Rank 1
Kevin asked on 27 Apr 2010, 01:19 PM
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("&nbsp;|&nbsp;");

                    linkButton1.Text = "" + (char)i;

                    linkButton1.CommandName = "alpha";
                    linkButton1.CommandArgument = "" + (char)i;

                    container.Controls.Add(linkButton1);
                    container.Controls.Add(lc);
                }

                LiteralControl lcLast = new LiteralControl("&nbsp;");
                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


1 Answer, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 29 Apr 2010, 01:22 PM
Hi Kevin,

Our system indicates, that you have opened a support ticket for this issue. To avoid duplicate posts, it will be best if we continue our communication in the relevant support ticket.

All the best,
Yavor
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Grid
Asked by
Kevin
Top achievements
Rank 1
Answers by
Yavor
Telerik team
Share this question
or