473,791 Members | 3,059 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Gridview dynamic columns

I'm modifying someone else's code and I have hit a snag. I don't
want
to rewrite what's already there but I might have to.

I have a gridview, in the gridview is a set number of columns that
will always be there. On the end of the gridview I need to add
columns
dynamically. These columns may or may not exist and I don't know how
many there will be. The way it is currently programmed, there are 2
gridviews, one for viewing a list and one for editing the list. So
the gridview is either being editted or it's being viewed. The way
the editted gridview is saved is by looping through each row, finding
the value in certain controls, and saving a list generated with the
values extracted.
Here's the problem, I can add and view columns in both gridviews by
adding new table cells to each row, but when I go to extract the
values within the code of the process described above, the gridview
doesn't have the additional columns. My question is, how do I add a
control to a gridview after it has been bound and then extract the
value from it? I'd prefer to not rewrite what's already there and
working, but is there an easier or better way to accomplish the same
goal? Thank you for your help in advance.
Apr 9 '08 #1
1 2786
Jimmy,
A GridView is an ASP.NET control, this is the C# language group. I think
you'll get a better response in the ASP.NET newsgroup.
-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short Urls & more: http://ittyurl.net
"jimmysjams " wrote:
I'm modifying someone else's code and I have hit a snag. I don't
want
to rewrite what's already there but I might have to.

I have a gridview, in the gridview is a set number of columns that
will always be there. On the end of the gridview I need to add
columns
dynamically. These columns may or may not exist and I don't know how
many there will be. The way it is currently programmed, there are 2
gridviews, one for viewing a list and one for editing the list. So
the gridview is either being editted or it's being viewed. The way
the editted gridview is saved is by looping through each row, finding
the value in certain controls, and saving a list generated with the
values extracted.
Here's the problem, I can add and view columns in both gridviews by
adding new table cells to each row, but when I go to extract the
values within the code of the process described above, the gridview
doesn't have the additional columns. My question is, how do I add a
control to a gridview after it has been bound and then extract the
value from it? I'd prefer to not rewrite what's already there and
working, but is there an easier or better way to accomplish the same
goal? Thank you for your help in advance.
Apr 9 '08 #2

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

Similar topics

3
13755
by: NateDawg | last post by:
I'm reposting this. I'm kinda in a bind untill i get this figured out, so if anyone has some input it would sure help me out. Ok, I’ve noticed a few gridview problems floating around the forum. Everyone wants to do a java confirmation box when a user clicks the delete button. Fair enough, basic user design rules state that you should always confirm a delete action. There is also a consensus that the best way to do this is a template...
0
1874
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...
0
1605
by: H5N1 | last post by:
Hi there It seems I've spotted interesting problem in a job I've got to do. I have 3 tables: meals, employees, and intersecting table: meals_for_employees with bool field meaning, that given employee wants a given meal. employees -----------------
3
14442
by: BartMan | last post by:
Greetings, I have a gridview which is sitting on a multi view control (witin a view), and it is bound to a dataset which I dynamically apply to the control within asp.net page. The problem is that I can't seem to resize my dataview's columns which are auto generated. Is there a way to do this? I have tried several different things, but I can't seem to get at the column collection to change the widths? MY development environment
4
8336
by: Ken Wigle | last post by:
All, I would be very grateful for any help on this question. I have an application in asp.net 2.0 where I dynamically create a datatable and then bind that to a gridview. Unfortunately, the date column always shows the date and time while I just want the short date. I have tried applying a format string {0:d} but to no avail. I saw a lot of posts regarding the htmlencode property but I do not know how to turn that off for a...
1
7854
by: spitapps | last post by:
In a traditional gridview control the items inserted(bind) into the control are rows and the data is in columns. I have a customer who wants the data fields as rows and the columns as the items being inserted(bind). I have never seen a gridview control displayed in this fashion but would like to use a control to accomplish this, so I am wondering if this is possible or if someone has an idea on how to accomplish this. Thanks. normal...
4
25536
by: Yin99 | last post by:
I have a Gridview binding to a DataTable source. I'd like to set the column with of the second column. I cannot do this apparently because when AutoGenerateColumns=true, they do not appear in the columns collection. I modified the RowCreated even to gridview, and I can change properties on the cells, but not width. (setting tooltip, background color, etc, all work but changing width has no effect). Here's sample code I am using:
4
11012
by: Craig Buchanan | last post by:
I dynamically add data-bound templates to a gridview in my ascx control. while this works correctly when the gridview is databound to the datatable, i'm having issues on postback. i would like to iterate thru the gridview's rows, examine the databound controls, then perform a database action. for some reason, i can't find the controls. i have a two templates: one that uses a label the other uses a textbox to display data. when the...
0
1266
by: Craig Buchanan | last post by:
I am adding templates to a gridview dynamically. these columns are based on data values that are generated prior to calling the gridviews databind. the challenge is when the form does a postback. i need to recreate these templates. until now, i've been storing the data needed to create the dynamic columns in a session variable. i was hoping to use the viewstate, but the viewstate isn't loaded until page_load. the gridview's templates...
0
9512
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10201
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
10147
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
9023
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6770
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5424
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
5552
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4100
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2910
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.