views:

18

answers:

2

Hi,

i'm doing a webshop in asp.net (c#). Is there a way to push the edit button in the gridview through the code of c#? I have a "new" button, that just adds the row, it would be great if that same row would "open" itself for editing without user having to press "new" then "edit"... I know there are other ways to do this, i just want to know if this is possible... it would save tons of time!! thanks in advance for the anwsers!!

Andrej

A: 

Just call the event handler you wrote to handle the edit button push.

EJC
tnx for the anwser.. i figured it out -> GridView.EditIndex = GridView.Rows.Count; ... viola!
Andrej
cool :) That's a better way to handle it anyway if you're always adding it to the end of the gridview.
EJC
A: 

Basically speaking, all that happens in code when you click a button is that the button's Clicked event is raised. In a GridView, the event is actually something like GridViewButtonClick. However many handlers you have plugged in will then execute (and you can't, and shouldn't have to, control the order of execution). For a built-in button, because you cannot raise the event from outside that button, you can simulate the button click by just calling the handlers you have attached to the event. If this were your own custom control, you could define a method you could call from outside that would cause the control to raise a certain event.

KeithS