473,387 Members | 1,597 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Dynamically adding columns to a WebForm datagrid

Hi everyone, I have a datagrid with a column template with one editbox.
Is it possible to add columns dynamically to this datagrid based on
the result set that comes back from a database query? I saw some
examples on how to add ASP code that defines bound columns, but the
number of columns varies according to the dataset. Is there any way to
do this from C# code?

Thanks,

Jun 20 '06 #1
1 1251
Here is a Microsoft article on creating column templates programmatically at
runtime.

http://msdn.microsoft.com/library/de...ridcontrol.asp

Scott

"herman404" wrote:
Hi everyone, I have a datagrid with a column template with one editbox.
Is it possible to add columns dynamically to this datagrid based on
the result set that comes back from a database query? I saw some
examples on how to add ASP code that defines bound columns, but the
number of columns varies according to the dataset. Is there any way to
do this from C# code?

Thanks,

Jun 20 '06 #2

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

Similar topics

2
by: Clayton Hamilton | last post by:
I have a DataGrid on a webform bound to a Datasource and can successfully use <ItemTemplate> to create edit/update/cancel functionality for user maintenance of data. I use separate logic to delete...
5
by: Phil Townsend | last post by:
I need to add a button to a datagrid. I have tried using the ButtonColumn and have also tried adding a button to a templatecolumn > itemtemplate. Whatever I have tried doesn't work, nor does it...
0
by: sameer mowade via .NET 247 | last post by:
Hello All, I have problem while dynamically removing row from the Datagrid which i have added dynamically as shown in the following code snippet. The problem is that while removing dynamically...
8
by: utterberg | last post by:
Hi I'm adding two dropdownlist in my webform by clicking a button. I fill the first dropdown with some values from my DB and the other one when I choose from the first dropdown. But since theese...
2
by: Pete Moss | last post by:
During a postback event, I am having trouble retrieving the state of a CheckBox Control that I am dynamically adding to a DataGrid Control using ASP.NET 1.1. I have no trouble adding the...
0
by: herman404 | last post by:
Hi everyone, I'm trying to dynamically add 3 button columns to a DataGrid object that I have on an ASP.net webpage, but I don't see any documentation on how to do it. I've seen plenty of examples...
1
by: herman404 | last post by:
Hi everyone, I have a datagrid with a column template with one editbox. Is it possible to add columns dynamically to this datagrid based on the result set that comes back from a database query? I...
3
by: rn5a | last post by:
A SqlDataReader is populated with the records from a SQL Server 2005 DB table. The records retrieved depends upon 2 conditions (the conditions depend on what a user selects in an ASPX page). If...
2
menayah
by: menayah | last post by:
Dear All, 1. I need to add columns to the datagrid dynamically in Vb .net web form how to that ? 2. How to make a scroll bar for the data grid ? 3. what is the best solution to view data...
5
by: tshad | last post by:
I found I can create Template columns dynamically - as long as I don't use objects that need onclick events, such as a LinkButton. Textboxes and Labels work fine. I create the Template columns...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
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...

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.