C# .NET - GridView1_RowCommand is not firing first time for the command

Asked By chitanya chitanya on 03-Jun-08 04:07 AM
how to add the event in page_init event

try this... - Vasanthakumar D replied to chitanya chitanya on 03-Jun-08 04:35 AM

Hi,

you can add the events to grid view as below...

GridView1.RowCommand += new GridViewCommandEventHandler(RowCommand);

and rowcommand method should be..

Private void RowCommand(object sender, GridViewCommandEventArgs e)

{

           //your code   

}

Do something like this - Sagar P replied to chitanya chitanya on 03-Jun-08 04:57 AM

This will help you .................. Here i have taken a class to handle event.

Let's say you want to handle the gridview's RowCommand event in your BLL.  I'll call the class GridViewEventHandlers and add one method with the correct signature as such:

public class GridViewEventHandlers
{
    public void HandleRowCommand(object sender, GridViewCommandEventArgs e)

    {

    }

}

Then in your code-behind create a module-level variable for the class:

GridViewEventHandlers _EventHandlers;

Then in the Page_Init event initialize the class and subscribe to the event:

protected void Page_Init(object sender, EventArgs e)
{

    _EventHandlers = new GridViewEventHandlers();

    GridView1.RowCommand += new GridViewCommandEventHandler(_EventHandlers.HandleRowCommand); 

For more details go thr this link;

http://forums.asp.net/p/1236864/2247689.aspx

Best Luck!!!!!!!!!!!
Sujit.

RowCommand - Shailendrasinh Parmar replied to chitanya chitanya on 03-Jun-08 05:32 AM

See the following article ::

http://
rePly - alice johnson replied to chitanya chitanya on 03-Jun-08 01:32 PM

code for the gridview event

GridView1.RowCommand += new GridViewCommandEventHandler(RowCommand);

In the rowcommand method write this

Private void RowCommand(object sender, GridViewCommandEventArgs e)

{

...........

}