Click here to Skip to main content
15,886,067 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello I am new in asp.net.
In my asp page i have a GridView control. in that control I have added a column as button. Now I want that when i will click the button, event will occure.

Now my question is where should I write code? means in which event of the gridview control.
Posted

Hi,

Set the button command property in source eg. "AddNew".

Go to Row Command event of gridview and type the following:

C#
if(e.CommandName == "AddNew"){
    //your code goes here..
}

This will help you.

All the best.
-AK
 
Share this answer
 
Comments
Mithlesh Shaw 19-May-12 1:15am    
How can I know that which number of row index has raised the event.
[no name] 19-May-12 2:48am    
To find row index use this: e.Row.RowIndex
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900