2

A nice good afternoon from Germany,

I have a asp:GridView and ButtonFields on the row with a RowCommand event.

protected void gridView_RowCommand(object sender, GridViewCommandEventArgs e)
{
    switch (e.CommandName)
    {
        case "FirstButton":
            this.DoSomething();
            break;
        case "SecondButton":
            this.DoSomethingElse();
            break;
    }
    this.BindDataGrid();
}

My Problem is in over 90% of all cases when I cklick on a ButtonField this event get's raised twice. The Problem with this is after I execute the this.DoSomething() or this.DoSomethingElse() the specific Line can't get executed agan.

thx
Marc

marcjohne
  • 141
  • 2
  • 9
  • 2
    After searching for a while I did come across this solution, the Image isn't shown jet but I think I will handle this. http://www.richard-slater.co.uk/archives/2010/04/01/asp-net-3-5-gridview-rowcommand-event-fired-twice/ – marcjohne Oct 15 '10 at 10:52

1 Answers1

0

why are you calling this.BindDataGrid? does your solution not work without this? that will cause a second run through of rowcommand.

Peter Kellner
  • 12,326
  • 22
  • 80
  • 154