dynamically adding columns to datagrid from sql statement

hi,

i have seen some of the datagrid samples in internet. In most of the cases the datagrid is bind to some table. But if i want to display the output of an sql query(contains select statement with n number of columns) in Datagrid, i can simply use AutogenerateColumns=true and populate the datagrid without having any bound columns. That is fine.

If i want to add some more extra columns like a checkbox column and an edit link button column i can do it using property builder. But,the problem is how can i order the columns in datagrid.

for example: 1st col: checkboxes
             2nd-4th col : from sql statemnt
             5th col : edit link button

Also how can i make a random column from sql statement to a hyperlink column.
i am using c# and asp.net 1.1

thanks
0
babu17
8/15/2006 3:50:18 PM
asp.net.presentation-controls 72751 articles. 3 followers. Follow

1 Replies
676 Views

Similar Articles

[PageSpeed] 45

Hi,babu17:

You should set AutogenerateColumns=false. Then you can use datagrid task to add columns and bind columns manually.




Best Regards,
__________________________________________________
Sincerely,
Rex Lin
Microsoft Online Community Support

This posting is provided "AS IS" with on warranties, and confers no rights.
0
rexlin
8/16/2006 9:00:57 AM
Reply:

Similar Artilces:

Dynamically adding columns with controls to a Datagrid
Hi all, I want to dynmically add rows and columns to a datagrid and also add controls(Textbox, dropdowns, etc) to the dynamically created cells. Please help with example codes. regards Subhajit Hi, Take a look @ : - Creating Controls Dynamically in ASP.NET - Creating DataGrid Programmatically - Creating DataGrid Templated Columns Dynamically HTHK B ShajudeenAreYaar.comDubai, United Arab Emirates....

Access dynamically added controls in datagrid column
Hi everyone,does anyone have any idea how to access the value in control in dynamically added column in datagrid?I have this 1 datagrid (datadatagrid) containing a list of data with checkboxes on each record.Once the checkbox is checked, it will be added dynamically to another datagrid (resultdatagrid) with a column in this datagrid containing a dropdownlist control.However when i want to access this resultdatagrid, it did not detect the controls.Does anyone have any idea why? and how to access this control in the dynamically added columns in the datagrid?Thanks..~lydia~...

Problems adding a dynamic control in a datagrid (with dynamic colums)
Basically I have an editable datagrid that will display any number of columns depending on what the current datasource is. When I want to edit a row I want each cell in the edit row to have two controls. The textbox control that contains the data being edited and button control that will move the text from the textbox to a large multi-line text box in a different panel. I am able to create the button dynamically however can't seem to get the click event to fire. Here is what I'm doing. Any help would be apreciated. My hunch is that I shouldn't be using the Page_Render event ...

Adding a column dynamically to a datagrid.
I have had success adding a column dynamically to a datagrid. However, the column is always added at the end. Can I add it to the front of the datagrid or specify where in the datagrids to add it ? Can you show me your code on how you are adding it? Dim col As New BoundColumn col.HeaderText = "Dynamically Added Column" col.ItemStyle.ForeColor = Color.CornflowerBlue col.HeaderStyle.ForeColor = Color.CornflowerBlue col.DataField = "control_ibs_branch" dgCustomersList.Columns.Add(col) Hi, Try AddAt as below: dgCustomersList.Columns.AddAt(index,c...

Adding columns to a datagrid dynamically
 I have a function which creates a datagrid by pulling some data from a DB. I then need to dip into the DB again and extract another set of data, this time it will be column names which I need to add to the original datagrid. This doesn’t seem to be working though. I have the following Dim dgColumns As New DataGrid Dim item As DataGridItem Dim col As BoundColumn dgColumns.DataSource = fillDS(<SQL>) dgColumns.DataBind() System.Diagnostics.Debug.WriteLine("New Columns: " + dgColumns.Items.Count.ToString) ...

Adding columns to datagrid dynamically
I need to create a spreadsheet that has total sales by each sales person. The first column has the name of the sales people. Then next columns have the sales totals for each person for each day of the month. This spreadsheet is created each day so that as the month goes on the number of columns grows. I need to know how I can add columns to the datagrid dynamically. Has anyone done this? Pleas help! Thanks, enak Personally, I'd recommend adding columns to the DataTable that is bound to the DataGrid, then rebinding it.This way you will always have the table and you won't have to do a bu...

Should I use DataGrid(add dynamic control) or just dynamic control?
Hi, I am debating between using just dynamic control's or actually adding the control's dynamically into a datagrid.  I have tried with just adding dynamically, but I am having so much trouble because the selectedindexchanged even it firing for no reason.  I have asked a lot of people, but nobody knows the answer for that and I searched in the web and I am not getting anything either. Now someone suggested to use DataGrid and add the control's dynamically.  In each row, I have a dynamic column, which could be 2 and above.  It will depends on a number that I get fromt he ...

Adding A Databound Column Dynamically in DataGrid
 i am trying to add column dynamically in Datagrid.now after creating boundcolumn  whenever trying to add it in Datagrid it gives me error of  "Object reference not set to an instance of an object." what is wrong with this code?Please Tell me thanks in advance. DataSet ds = new DataSet();   ds = getDataset(); // here Dataset has two column named "ID" and "Name"          BoundColumn[] name = new BoundColumn[12];   // Array of Bound Column  for (int i = 0; i < ds.Tables[0]...

Adding dynamically created column to datagrid
Dear all, I want to add a dynamically created column to a specific position of the grid. i..e i have a datagrid of five column, i want to add the dynamically created column after second column, so that the datagrid becomes of six columns with the dynamically created column being it's third column. Please, tell me how to do it (with code example). regards munas This article should help you get started: Top Questions about the DataGrid Web Server Control Contents Windows Forms versus Web Forms DataGrid Controls Controlling Column Width, Height, and Alignment ...

Dynamicly Adding / Removing Columns to/from the DataGrid
Does anyone have a good tutorial on Adding / Removing Columns from a DataGrid at runtime? Hi, you can check the Top Questions about DataGrid Control [MSDN] out Other resources 1. C#/ASP.NET - Adding Columns to DataGrid Programmatically    (adding columns)2. Creating Templates Programmatically in DataGrid Control (adding template column)3. Hide Columns in DataGrid Hope this helps you...Alvin ChooiMicrosoft ASP.NET™ Enthusiast v1.1 / v2.0, Malaysia Blog : http://alvinzc.blogspot.com...

Adding Columns dynamically to a datagrid view
Hi,     I am using ASP.NET 2.0 (Visual Studio 2005). I have a requirement to display data in a single row (data coming from multiple rows) for example:  Consider a table called "ANALYSIS" which contains data from another table called "COMPLAINT", it has a one to many relation ship with that table. Now the data in the "ANALYSIS" table is somewhat like this: ID |  Name  |  UserComments | AssigneeComments | ComplaintId 1  | Ammar |              &nb...

adding columns to datagrid dynamically #2
hi, i want to add the column to datagrid dynamically.......... how can i do this in asp.net... i want to add image button to that column... Friend, here are couple of articles on this area explaining how to create the columns dynamically to the Datagrid http://www.codeproject.com/KB/aspnet/DataGrid_Template_columns.aspx http://www.csharpfriends.com/Articles/getArticle.aspx?articleID=332 http://www.odetocode.com/Articles/218.aspx http://www.dnzone.com/ShowDetail.asp?NewsId=599 Good luck!   Please Don't forget to click "Mark as Answer" on the post that helped y...

adding dynamic controls into a datagrid cell
Hi, i am having a problem rendering dynamic controls into a datagrid . I have a datagrid with 2 columns. The first column is a static one , i created it at the design time the second column is a dynamic column i created. In this column i am adding dynamic controls , i have 4 controls( 1 TextBox, 2 buttons one Add and one Remove, 1 ListBox) and hence to align them i am using a dynamic table When i enter some text in the TextBox and click add button it is posted back to the server and add button eventhandler adds the TextBox content to the ListBox. When i hit Remove butto...

Dynamically adding columns to DataGrid through C#
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,...

Web resources about - dynamically adding columns to datagrid from sql statement - asp.net.presentation-controls

Placebase team at Apple file “Schematic Maps” patent dynamically detailing important data
In a report from Computerworld way back in 2009, we learned that Apple had quietly acquired Maps API company Placebase. Then, founder of Placebase ...

Apple's Lightning port dynamically assigns pins to allow for reversible use
... a closer look at how Apple's new Lightning connector works, and has come to the conclusion that the 8 pins on each side of the plug are dynamically ...

In a dynamically typed language, is it a bad idea to return different data types?
In some cases, returning different types from a single function works.

Urlbox Launches Screenshots-as-a-Service Platform to Dynamically Update Galleries
... changes. Launched yesterday, Urlbox allows anyone with a gallery displaying website screenshots to automate the process and keep them dynamically ...

Everything.me launcher dynamically adapts to what you’re doing right now
... phone according to what you’re doing. Perform a search for ‘football’ and your background will change to the NFL logo. A launcher that dynamically ...


A YouTube Experiment Resizes the Player Dynamically
There's a new YouTube experiment that changes the video player's size, depending on the browser window's size. When resizing Chrome's window, ...

Apple Granted “Dynamically Changing Cursor for User Interface” Patent, Originally Filed in 2003
... a utility patent that covers the use of the mouse cursor that changes according to the context of the task it is engaged in. Called a “Dynamically ...

Atmel's FPSLIC II Dynamically Reconfigurable SoC Supports "Silicon-Sharing" For Peripherals & Interfaces ...
Silicon-Sharing Fits 200K Gate Design into 40K Gate FPSLIC II's, Cuts Power Drain by 97%

Everything.me Launcher Wants to Dynamically Change Phones Based on Location, Interests, and Mental State ...
What if your phone’s launcher dynamically changed based upon interests, your location, or topics you had in mind at a specific moment? A new ...

Resources last updated: 11/24/2015 2:16:20 AM