GridView Row

Can any body tell me how I can do this.

I have made a custom template field in my grid view, this contains a button which links to a function in the code.

here is the small function

    protected void Process_Click(Object sender, GridViewRowEventArgs e)
        String value1 = e.Row.Cells[3].Text.ToString();
        value.InnerHtml = value1;

But I cannot get it to work and get this error

Error      1      No overload for 'Process_Click' matches delegate 'System.EventHandler'      C:\Documents and Settings\REA_A\Desktop\test\c_sharp_tests\WebSite2\Default.aspx      39      

Thanks in advance,

LVL 20
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

REA_ANDREWAuthor Commented:
is there an easier way to get a cells value on a certain row dependant on the button I click?
Ramesh SrinivasTechnical ConsultantCommented:
I think you have to create a handler for the button click event.

Something like:

NameOfYourButtonHere.Click += new EventHandler(this.Process_Click);

I think that is it anyway :O
REA_ANDREWAuthor Commented:
I am having trouble with that, as the intellisense is not recognising My button at all. I was going to put that code in the Page_Load handler
Rowby Goren Makes an Impact on Screen and Online

Learn about longtime user Rowby Goren and his great contributions to the site. We explore his method for posing questions that are likely to yield a solution, and take a look at how his career transformed from a Hollywood writer to a website entrepreneur.

Create the event handler for GridView.RowCommand and then put your code in there.

Buttons inside a GridView are duplicated depending on how many rows you have so you cannot pick up the button on_Click only that the Row has sent a command.

Take a look and let me know if you need more help.
REA_ANDREWAuthor Commented:
I used a work around for now but I will try that too.  My problem now is that one, I use a command field that selects the row.  This is how I have got My row number.

My first column is hidden, BUT i need its value.  I have assigned the columns data keys but I do not know how to retrive these, say if I use  GridView1.SelectedRow <-----DataKeys is not a memeber of this.

Can you help>

Thanks so far guys

Since you have your RowNumber you should just be able to do something like


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
REA_ANDREWAuthor Commented:
Cheers Again Gavin, That sorted spot on.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.