GridView Row

Posted on 2006-04-19
Last Modified: 2012-06-27
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,

Question by:REA_ANDREW
    LVL 20

    Author Comment

    is there an easier way to get a cells value on a certain row dependant on the button I click?
    LVL 11

    Expert Comment

    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
    LVL 20

    Author Comment

    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
    LVL 15

    Expert Comment

    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.
    LVL 20

    Author Comment

    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

    LVL 15

    Accepted Solution

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

    LVL 20

    Author Comment

    Cheers Again Gavin, That sorted spot on.


    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
    It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now