473,692 Members | 2,160 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 AutoGenerateCol umns 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 programmaticall y is
inserted at the start (first column in GridView).

If I disable AutoGenerateCol umns, 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 programmaticall y create them.

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

AutoGeneratedCo lumns and inserting a column at the end of the GridView
programmaticall y,
or,
Not using AtuoGeneratedCo lumns, declaretively creating the first 4 columns
and then programmaticall y creating the x amount of columns.

Thanks in advance.
Nov 19 '05 #1
3 2477
TJS
typically, I autogenerate the columns, then programmaticall y 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 programmaticall y 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 programmaticall y add additional
ones from there.


Nov 19 '05 #3
TJS
try something like this

'************** *************** *************** ***********
Sub Page_Init(sende r 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.DataNavigat eUrlField="repo rtsID"
hc1.DataNavigat eUrlFormatStrin g= "Report.aspx?rp t={0}"
hc1.Text="View"
PatientReportGr id.Columns.Add (hc1)

End Sub


"Mark Parter" <Ma********@dis cussions.micros oft.com> wrote in message
news:52******** *************** ***********@mic rosoft.com...
Yeah, but autogenerated columns aren't added to the GridView's columns
collection so any columns programmaticall y 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 programmaticall y 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
6333
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 correctly but it is not updating or deleting the rows. What I did was, in design view, added a gridview control and added an sqldatasource control. I configured the data source to update and delete. In the gridview tasks I selected enable...
5
4834
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 automatically if the data doesn't change. But if records have been added or deleted then it looks as if some code is necessary: I've done this by using GridView.SelectedValue to get the key value of the currently selected Row and then by itterating...
2
3566
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 = lobj_Standard_Values_Fields_DataRow.Header_Text lobj_TemplateColumn.ItemTemplate = New GridViewTemplate( _
0
1869
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 GridView - each row has an edit button and clicking on this should trigger that record to be loaded into the DetailsView for editing. The problem is that the record never gets loaded into the DetailsView. Instead, the DetailsView always and only...
3
1975
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 combobox and click the "get orders" button to refresh the gridview with the selected customer's orders, via a GetDataByCustomerID stored procedure. The underlying Orders table includes, among others, three boolean columns and one particular...
2
2447
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 just trying to work out how the GridView control works (i.e. what it does for me behind the scenes). i.e. When I retrieve data to display in my GridView is a reload of the page from the server required?
2
8987
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 object (custom class) is created, and properties are populated in each step of the wizard. In one of the steps, the User is assigned to 1 or more Programs. Assigned Programs are stored by the User object in a List, and displayed in a GridView in the...
1
12218
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 Access into a Gridview (Gridview1), in which I have AutoGenerateEditButton set to True. What I want is this: when a user clicks "Edit" on a line and it goes to edit mode, I want to grab the supplier's category (4th column of the grid, named...
0
1547
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. I have the buttons for both visible, and when I click edit, the update fields show up properly, but once I click 'update' the table is back with it's old information. When I click 'delete' the page completes the postback properly, but once again, the...
3
5596
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 me here. Thanks.
0
8610
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9090
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8968
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8810
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8810
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6462
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4327
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4562
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2242
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.