473,847 Members | 1,452 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

dynamic column/fields

ER
Hi,

I would like to create a datagrid or free entry form with dynamic columns
based on the user selection, do you have any ideas or samples?

Any help would be appreciated!

ER
Jan 7 '06 #1
3 1386
The datagrid server control provides a property named AutoGenerateCol umns
that would allow the grid to display any number of columns that are on the
datatable.
http://msdn2.microsoft.com/en-us/lib...tecolumns.aspx

You can make the datagrid editable by adding an EditCommandColu mn
http://msdn2.microsoft.com/en-us/lib...andcolumn.aspx

Another alternative is to turn the AutoGenerateCol umns to false and then
compose the columns programmaticall y during databinding like this:
private void dgItems_DataBin ding(object sender, System.EventArg s e)
{
DataTable dt = (DataTable)dgIt ems.DataSource;
for( int c=1; c<dt.Columns.Co unt; c++ )
{
BoundColumn bc = new BoundColumn();
bc.DataField = dt.Columns[c].ColumnName;
bc.HeaderText = dt.Columns[c].ColumnName;
dgItems.Columns .Add( bc );
}
}

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"ER" wrote:
Hi,

I would like to create a datagrid or free entry form with dynamic columns
based on the user selection, do you have any ideas or samples?

Any help would be appreciated!

ER

Jan 7 '06 #2
ER
Thanks Phillip. For the second solution, would that affect the performance if
the datagrid has significant data to display?

Thanks,
ER

"Phillip Williams" wrote:
The datagrid server control provides a property named AutoGenerateCol umns
that would allow the grid to display any number of columns that are on the
datatable.
http://msdn2.microsoft.com/en-us/lib...tecolumns.aspx

You can make the datagrid editable by adding an EditCommandColu mn
http://msdn2.microsoft.com/en-us/lib...andcolumn.aspx

Another alternative is to turn the AutoGenerateCol umns to false and then
compose the columns programmaticall y during databinding like this:
private void dgItems_DataBin ding(object sender, System.EventArg s e)
{
DataTable dt = (DataTable)dgIt ems.DataSource;
for( int c=1; c<dt.Columns.Co unt; c++ )
{
BoundColumn bc = new BoundColumn();
bc.DataField = dt.Columns[c].ColumnName;
bc.HeaderText = dt.Columns[c].ColumnName;
dgItems.Columns .Add( bc );
}
}

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"ER" wrote:
Hi,

I would like to create a datagrid or free entry form with dynamic columns
based on the user selection, do you have any ideas or samples?

Any help would be appreciated!

ER

Jan 9 '06 #3
I think that the performance would be the same.

If the only requirement in building the datagrid were to display all columns
without exception, such as the sample code below, then I prefer using the
declarative syntax (the first solution) because it makes the code more
readable and easily maintainable (one can change it without recompiling the
application).

If, on the other hand, one has to use different conditions for columns that
may or may not be provided in the data or if one has to hide particular
columns if they happen to exist in the data then the second approach would
work better.
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"ER" wrote:
Thanks Phillip. For the second solution, would that affect the performance if
the datagrid has significant data to display?

Thanks,
ER

"Phillip Williams" wrote:
The datagrid server control provides a property named AutoGenerateCol umns
that would allow the grid to display any number of columns that are on the
datatable.
http://msdn2.microsoft.com/en-us/lib...tecolumns.aspx

You can make the datagrid editable by adding an EditCommandColu mn
http://msdn2.microsoft.com/en-us/lib...andcolumn.aspx

Another alternative is to turn the AutoGenerateCol umns to false and then
compose the columns programmaticall y during databinding like this:
private void dgItems_DataBin ding(object sender, System.EventArg s e)
{
DataTable dt = (DataTable)dgIt ems.DataSource;
for( int c=1; c<dt.Columns.Co unt; c++ )
{
BoundColumn bc = new BoundColumn();
bc.DataField = dt.Columns[c].ColumnName;
bc.HeaderText = dt.Columns[c].ColumnName;
dgItems.Columns .Add( bc );
}
}

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"ER" wrote:
Hi,

I would like to create a datagrid or free entry form with dynamic columns
based on the user selection, do you have any ideas or samples?

Any help would be appreciated!

ER

Jan 9 '06 #4

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

Similar topics

8
1698
by: Drew | last post by:
I am trying to build a small app that shows a Course Title from the database, then displays a dropdown full of categories for the user to choose one... I thought a loop would be the best way to accomplish this, but since the dropdown is dynamic, I am having problems. Can someone help me out here? Here is my code, For i = 1 to Num
3
3720
by: CSDunn | last post by:
Hello, I have a situation with MS Access 2000 in which I need to display report data in spreadsheet orientation (much like a datasheet view for a form). If you think of the report in terms of what a spreadsheet might show, the column names will actually be dynamic, based on data from a SQL Server 2000 database. The row data will also come from the same database. So in this case, I will have a main report and a subreport. I've already tried...
1
17691
by: Nathan Bloomfield | last post by:
Does anyone know if there is any documentation which relates to Access2k + ? or can anyone help adjust the code? I am having trouble converting the DAO references. TITLE :INF: How to Create a Dynamic Crosstab Report PRODUCT :Microsoft Access PROD/VER:1.00 1.10 OPER/SYS:WINDOWS
0
427
by: CSDunn | last post by:
Hello, I have a format issue on an Access 2000 ADP report that I am going to attempt to explain from a 'ten thousand foot view' : I have an Access 2000 ADP report that has a SQL Server 2000 Stored Procedure as its record source. The Proc is called MM_rptTeacherGroupingTest_sp. In order to help communicate the issue I am having with the report, please take a look at the following: http://www.valverde.edu/home/policy/ReportLayout.htm .
1
3345
by: Richard Hollenbeck | last post by:
Hello Newsgroup. You have all been very helpful in the past and I thank you. I try to ask relevant questions so that they don't just benefit me, but also benefit the group. I'm currently overwhelmed by useless examples across the web on how to make "dynamic crosstab reports" without myself having a basic understanding about how to retrieve and assign recordsources, etc., from fields in a query to fields in the report. I see all these...
3
13763
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...
2
2947
by: deejayquai | last post by:
Hi I'm trying to produce a report based on a dynamic crosstab. Ultimately i'd like the report to actually become a sub report within a student end of year record of achievement. The dynamic sub-report will capture what grades the student has achieved in a list of different subjects and the reason I need it to be dynamic is that students take different subjects. Basically I've been trying to doctor the KB article on dynamic
13
17173
by: salad | last post by:
Operating in A97. I didn't receive much of a response conserning Pivot tables in Access. Pivot tables are nice, but a CrossTab will work for me too. Using a Pivot table, one is actually launching Excel for data viewing. I'd prefer the user stay in Access. Creating dynamic crosstab queries is pretty simple. The problem is that the column count may shrink or grow depending on the filter.
4
5471
by: Bongard | last post by:
I have a dynamic range that I would like to use as a linked table into Access. The problem is that Access doesn't seem to want to to recognize the dynamic range when you click on "show named ranges" in the Link Spreadsheet wizard. The reason I want to use a dynamic range is because when the data in my excel spreadsheet changes the linked table will import blank rows that were previously used from the bottom of the spreadsheet. I can't...
14
7869
ollyb303
by: ollyb303 | last post by:
Hi, I am trying to create a dynamic crosstab report which will display number of calls handled (I work for a call centre) per day grouped by supervisor. I have one crosstab query (Query1) which has the following fields: SPID (supervisor ID), total:group by, as row heading Date, total:group by, as column heading Calls handled, total:sum, as value Date, total:where, criteria between and - this is taken from a form,
0
9892
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
10653
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...
0
9490
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
7061
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
5725
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
5915
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4540
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
2
4129
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3168
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.