Struggling with GridView
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Struggling with GridView

  1. #1
    Join Date
    Apr 2004
    Location
    Toronto, Canada
    Posts
    108

    Struggling with GridView

    Greetings:

    I have a web app here in which I would like to use one user pane to allow the user to make certain selections and, upon clicking "Go", another larger pane will use a GridView to display records obtained from a database. The number of columns and fomat of the columns in the resulting GridView would vary depending on the selection that the user makes.

    So, I thought it would be best to create and format the GridView columns using server-side code (I'm using VS 2008, ASP.NET 3.5 and C#). However, I'm finding this to be horrendously difficult. Every example that I am seeing seems to want to set up the Grid View and the associated data source apriori in the ASPX code file.

    My interpretation of things was: Any and all settings and attributes that can appear for an ASP web control on the client side ASPX file, can be analogously written at application run time by server side code. So, in other words, if an SqlDataSource object is placed in the ASPX file and has the following attributes set:

    HTML Code:
    <asp:SqlDataSource ID="sqlGPSRecSrc" runat="server" 
    	ConnectionString="MyConnectionString" 
    	SelectCommand="SomeStoredProcedure" 
            SelectCommandType="StoredProcedure" 
    	ProviderName="System.Data.SqlClient" />
    then, I could just as easily do this instead:

    HTML Code:
    <asp:SqlDataSource ID="sqlGPSRecSrc" runat="server" />
    and, when the time comes, execute server-side code that goes like this:

    Code:
    sqlGPSRecSrc.ConnectionString = "MyConnectionString";
    sqlGPSRecSrc.SelectCommand="SomeStoredProcedure";
    sqlGPSRecSrc.SelectCommandType="StoredProcedure";
    sqlGPSRecSrc.ProviderName="System.Data.SqlClient";
    I have left out all the stuff where you set up the parameters for calling the stored procedure, but you get my point I hope.

    The problem seems to be that when I execute the code to configure the GridView and the DataSource and bind the two together, the result I get is nothing. The panel that is supoosed to contain the GridView is completely blank.

    Is there something I'm missing? Is there some reason why I can't do what I am proposing?

    My database is SQL 2008 and I'm using stored procedures for the record retrieval. The stored procedures require input parameters. All of this has been tested and is working well.

    Thank you to anybody that responds to this.
    Mark

  2. #2
    Join Date
    Jan 2011
    Posts
    16

    Re: Struggling with GridView

    Hi!

    I tend to believe that AjaxTemplates is suitable for your solution
    Read http://msdn.microsoft.com/en-us/library/dd448879.aspx

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center