February 14th, 2011, 10:25 AM
Struggling with GridView
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:
then, I could just as easily do this instead:
<asp:SqlDataSource ID="sqlGPSRecSrc" runat="server"
and, when the time comes, execute server-side code that goes like this:
<asp:SqlDataSource ID="sqlGPSRecSrc" runat="server" />
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.
sqlGPSRecSrc.ConnectionString = "MyConnectionString";
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.
February 14th, 2011, 12:30 PM
Re: Struggling with GridView
I tend to believe that AjaxTemplates is suitable for your solution
Click Here to Expand Forum to Full Width
This is a CodeGuru survey question.