473,508 Members | 2,805 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

GridView help required

I have a GridView control which is bound to a Stored Procedure (SP) using a
SQLDataSource. The problem I'm having is that the SP returns 4 known columns
and x amount of unknown columns.

I can use the AutoGenerateColumns feature to render all the returned columns
but I'm then having problems adding in 1 column at the right of the GridView
at runtime. This is because AutoGenerated columns aren't added to the
GridView's columns collection so any column created programmatically is
inserted at the start (first column in GridView).

If I disable AutoGenerateColumns, I can declaretively create the first 4
columns as I know what they are but there can be anywhere between 1-18
additional columns after this, with unknown column names (it's a crosstab
SP). With this method, I can't think of a way to find out how many "extra"
columns there are and programmatically create them.

Any advise/inspiration appreciated on how to approach this using either;

AutoGeneratedColumns and inserting a column at the end of the GridView
programmatically,
or,
Not using AtuoGeneratedColumns, declaretively creating the first 4 columns
and then programmatically creating the x amount of columns.

Thanks in advance.
Nov 19 '05 #1
3 2464
TJS
typically, I autogenerate the columns, then programmatically add additional
ones from there.


Nov 19 '05 #2
Yeah, but autogenerated columns aren't added to the GridView's columns
collection so any columns programmatically added to the gridview are added at
the beginning of the GridView.

Unless you can tell me how to set it up so that columns are added AFTER the
bound columns?

"TJS" wrote:
typically, I autogenerate the columns, then programmatically add additional
ones from there.


Nov 19 '05 #3
TJS
try something like this

'************************************************* ******
Sub Page_Init(sender As Object, e As EventArgs)
'
' dynamically add column to the datagrid
' This must be done in the Page_Init function
'
'************************************************* ******
Dim hc1 as new HyperLinkColumn
hc1.DataNavigateUrlField="reportsID"
hc1.DataNavigateUrlFormatString= "Report.aspx?rpt={0}"
hc1.Text="View"
PatientReportGrid.Columns.Add (hc1)

End Sub


"Mark Parter" <Ma********@discussions.microsoft.com> wrote in message
news:52**********************************@microsof t.com...
Yeah, but autogenerated columns aren't added to the GridView's columns
collection so any columns programmatically added to the gridview are added
at
the beginning of the GridView.

Unless you can tell me how to set it up so that columns are added AFTER
the
bound columns?

"TJS" wrote:
typically, I autogenerate the columns, then programmatically add
additional
ones from there.


Nov 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
6308
by: | last post by:
Hello, I have created an ASP.NET 2.0 application that utilized a Gridview Control to display and update/delete data. The problem I am having is that the gridview control is displaying the data...
5
4824
by: Dick | last post by:
I have a GridView bound to an ObjectDataSource. I have a Button that calls GridView.DataBind. I want the row that is selected before the DataBind to still be selected afterwards. This happens...
2
3558
by: GCeaser | last post by:
All, I am attempting to use the following code to add a TemplateColumn to my GridView programatically: lobj_TemplateColumn = New TemplateColumn lobj_TemplateColumn.HeaderText =...
0
1864
by: jeffmagill | last post by:
Hi Everybody, I'm really hoping that someone can help me out because I have spent too much time on this project already! Basically, I have a DetailsView that handles all the Edits for a...
3
1969
by: Richard Carpenter | last post by:
I have a simple winform with a customers combobox, a "get orders" button and an orders grid. Due to other requirements, I have implemented the form to allow the user to select a customer from the...
2
2440
by: Angel Of Death | last post by:
When you use the ObjectDataSource with the GridView ASP.NET control is it the client (browser) that makes the SOAP request required for interaction with the WebService or is it the server? I'm...
2
8976
by: Greg | last post by:
Hello, I am trying to bind a GridView to a custom object I have created. First, here is what I'm trying to do: I have a wizard for adding/editing Users. When the wizard begins, a User...
1
12206
by: cyningeston | last post by:
OS: WinXP Pro, VB/ASP/ADO.NET I'm building a web-based supplier management application. For each supplier we are required by the FDA to track certain documents. I've managed to pull them from...
0
1538
by: TheDebbis | last post by:
I'm making a quick CD catalog to help me learn ASP.NET (using C# primarily.) I have a number of gridview's on my site that are working properly, but for some reason, one is not updating or deleting....
3
5582
by: Nathan Sokalski | last post by:
I have a GridView with a ButtonField. In the RowCommand I need to use the value of one of the fields used in that row. I am having trouble doing this, so I would appreciate it if someone could help...
0
7398
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7061
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7502
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5637
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5057
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4716
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3194
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
769
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
428
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.