0
votes

I have a GridView with bound rows from a data source and I placed a link button at the end of each row. When I click that link button I would find the named controls within the grid and get their values. I decided to try and use a Repeater control with the same named controls in the Repeater and same data source but I am not able to execute the same click event and use RepeaterItemEventArgs, only EventArgs is available in the method signature. Without the RepeaterItem I can't find the control.

This code compiles but when I click the row I get this error: CS0123: No overload for 'BtnAssign' matches delegate 'System.EventHandler' So I discovered that what I needed was to change the second parameter to EventArgs. This fixes the error at run time and I am able to step into this method but the method has to be changed in order to compile. I no longer have access to e.Item. Ideas?

protected void BtnAssign(object sender,  RepeaterItemEventArgs e)
    {
        var miscItem = new SLWorkOrderItem();
        string theAmountLabelText = "";

        // Repeater Code
        if (e.Item.ItemType == ListItemType.Item)
        {
            var theAmountLabel = e.Item.FindControl("lblAmount") as Label;

        }
    }
1
I'm really sure that a GridView and a Repeater have different arguments for that event. You might be better off with having the be separate functions. - gunr2171
Which control does fire BtnAssign event? Please post the mark up. - Win

1 Answers

0
votes

I am guessing you are trying to execute this on the ItemCommand Event?

In that case: You would use RepeaterCommandEventArgs not RepeaterItemEventArgs.

http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.repeateritemeventargs.aspx

RepeaterItemEventArgs is used in ItemCreated.

            OnItemCommand="BtnAssign"

            protected void BtnAssign(object source, RepeaterCommandEventArgs e)
                {

                }