Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Formatting datagrids at run time

Reply
Thread Tools

Formatting datagrids at run time

 
 
coleenholley
Guest
Posts: n/a
 
      01-29-2004
Hi all :-

I have a datagrid which is populated from a class module (we have to do this because of the type connection we use -we DON'T use an SQL Server connection) the code populates the datatable at runtime. I need to specify column widths in the data grid in order to get the look & Feel correct for our users. I create the data column headers using

dt_worksheet1.Columns.Add(New DataColumn("County")) ... in the VB code and populate using

ls_temp_arr = ls_temp.Substring(li_county_name, li_county_name_len).Trim(
ls_county = ls_temp_arr.ToString().Tri
dr_gallons(0) = ls_count

the problem is that some of the headers are longer and won't wrap correctly. I know that if I use bound datacolumns in the datagrid I can specify the column width, but because of the way we populate the datagrid, when I set the bound columns, the datagrid won't populate. Any way to do this programatically in the VB code behind? Thanks for any help/suggestions

Coleen

---
Posted using Wimdows.net NntpNews Component - Posted from .NET's Largest Community Website: http://www.dotnetjunkies.com/newsgroups/
 
Reply With Quote
 
 
 
 
Scott Allen
Guest
Posts: n/a
 
      01-30-2004
Hi Coleen:

You can programtically add bound columns to a DataGrid (see below).
I'm assuming you are using ASP.NET since this is the ASP.NET
newsgroup, but I'm not aware of a single, simple property you can set
to control column width in the web forms datagrid.

BoundColumn c = new BoundColumn()
c.DataField = "DataField";
c.DataFormatString = ...
c.SortExpression = ...
....
DataGrid1.Columns.Add(c);

HTH,

--
Scott
http://www.OdeToCode.com


On Thu, 29 Jan 2004 15:39:02 -0800, coleenholley wrote:

>Hi all
>
>I have a datagrid which is populated from a class module (we have to do this because of the type connection we use -we DON'T use an SQL Server connection) the code populates the datatable at runtime. I need to specify column widths in the data grid in order to get the look & Feel correct for our users. I create the data column headers using:
>
> dt_worksheet1.Columns.Add(New DataColumn("County")) ... in the VB code and populate using:
>
>ls_temp_arr = ls_temp.Substring(li_county_name, li_county_name_len).Trim()
>ls_county = ls_temp_arr.ToString().Trim
>dr_gallons(0) = ls_county
>
>
>the problem is that some of the headers are longer and won't wrap correctly. I know that if I use bound datacolumns in the datagrid I can specify the column width, but because of the way we populate the datagrid, when I set the bound columns, the datagrid won't populate. Any way to do this programatically in the VB code behind? Thanks for any help/suggestions.
>
>Coleen
>
>---
>Posted using Wimdows.net NntpNews Component - Posted from .NET's Largest Community Website: http://www.dotnetjunkies.com/newsgroups/


 
Reply With Quote
 
 
 
 
coleenholley
Guest
Posts: n/a
 
      01-30-2004
Thanks for your help Scott :-

Yes, I'm using ASP.Net, with VB code-behind. I've got the columns all coming correctly using the VB Class module in the code-behind, but the column widhts are set to auto-generate at run-time. The problem with this is that in the datagrid properties, when I set it to auto-generate, the column widths do not generate how I want them to look. If I bind to the datacolumns, because of the way we connect to DB2 using an RPC from COBOL the data is not populated into the datagrid. I'm sure there has to be a way to do this...

---
Posted using Wimdows.net NntpNews Component - Posted from .NET's Largest Community Website: http://www.dotnetjunkies.com/newsgroups/
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Run-time template list definition / Run-time variable type definition Pierre Yves C++ 2 01-10-2008 02:52 PM
Is time.time() < time.time() always true? flamesrock Python 8 11-24-2006 06:51 AM
page formatting problem with tables and datagrids - especially printing mark ASP .Net 2 06-09-2004 08:32 AM
Formatting Datasets (and a quick question on datagrids) Mike Fellows ASP .Net 0 03-03-2004 04:50 PM
Formatting a time field to 24 hour time (Military time) in the Datagrid David Hearn ASP .Net Datagrid Control 1 09-10-2003 02:50 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57