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,

ANdrew
LVL 20
REA_ANDREWAsked:
Who is Participating?
 
GavinMannionCommented:
Since you have your RowNumber you should just be able to do something like

GridView1.SelectedDataKey["MyKey"]
0
 
REA_ANDREWAuthor Commented:
is there an easier way to get a cells value on a certain row dependant on the button I click?
0
 
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
0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

 
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
0
 
GavinMannionCommented:
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.
0
 
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

Andrew
0
 
REA_ANDREWAuthor Commented:
Cheers Again Gavin, That sorted spot on.

Cheers
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.