Results 1 to 4 of 4

Thread: gridview rowdatabound problem

  1. #1

    Thread Starter
    PowerPoster MMock's Avatar
    Join Date
    Apr 2007
    Location
    Driving a 2018 Mustang GT down Route 8
    Posts
    4,475

    gridview rowdatabound problem

    This shouldn't be this difficult to solve but I cannot do it (I think I've been staring at it too long).

    Here's my gridview

    Code:
            <asp:GridView ID="gvProviders" 
                runat="server"
                GridLines="None" 
                AllowPaging="true" 
                AutoGenerateColumns="False" 
                AllowSorting="True" 
                OnSorting="gvProviders_Sorting" 
                CssClass="grid-style" 
                HeaderStyle-CssClass="header-style" 
                RowStyle-CssClass="row-style" 
                AlternatingRowStyle-CssClass="alternating-row-style"
                PageSize="25"
                OnPageIndexChanging="gvProviders_PageIndexChanging"
                OnRowDataBound="gvProviders_RowDataBound"
    Here's my code
    Code:
            protected void gvProviders_RowDataBound(object sender, GridViewRowEventArgs e)
            {
                if (e.Row.RowType == DataControlRowType.DataRow)
                {
                    // Display the company name in italics.
                    Label lblQAndA = (Label)e.Row.FindControl("lblSecurityQAndA");
                    DataRowView drv = (DataRowView)e.Row.DataItem; 
                    lblQAndA.Text = drv["Question"].ToString() + " " + drv["Answer"].ToString()
                }
    
            }
    Error is Compiler Error Message: CS1061: 'ASP.searchprovider_aspx' does not contain a definition for 'gvProviders_RowDataBound' and no extension method 'gvProviders_RowDataBound' accepting a first argument of type 'ASP.searchprovider_aspx' could be found (are you missing a using directive or an assembly reference?)



    Why can't it find 'gvProviders_RowDataBound'?
    There are 10 kinds of people in this world. Those who understand binary, and those who don't.

  2. #2
    ASP.NET Moderator gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: gridview rowdatabound problem

    Hello,

    Have you changed anything higher up in your page? Normally this type of error appears when you have modified the namespace for either the code behind page, or the ASPX page. As a result, the hook up between the two pages is "lost".

    If you can't find anything obvious, remove the page from the project, and move it somewhere else on your hard drive. Create a new page, and then copy back in the relevant sections of the code, i.e. everything in the form tag on the ASPX page, and everything within the class definition in teh code behind.

    Sometimes this is the quickest approach.

    Gary

  3. #3

    Thread Starter
    PowerPoster MMock's Avatar
    Join Date
    Apr 2007
    Location
    Driving a 2018 Mustang GT down Route 8
    Posts
    4,475

    Re: gridview rowdatabound problem

    Okay then, so it's not something obvious. Right now I am doing without the RowDataBound event being called while I work on another piece, but I will try what you said when I need to execute it. Thanks (I did try just closing/restarting Visual Studio but that didn't help. I don't know why gvProviders_Sorting and _PageIndexChanging work - isn't it the same idea?)
    There are 10 kinds of people in this world. Those who understand binary, and those who don't.

  4. #4
    ASP.NET Moderator gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: gridview rowdatabound problem

    Hello,

    Yes, if it is the problem that I am thinking about, then I would expect that all the EventHandlers would exhibit the same problem.

    Gary

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width