473,385 Members | 1,930 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,385 software developers and data experts.

Setting a column width of a Template column programatically

Hello Everyone,

I have been successful in creating a template column programatically using
the examples provided in VS 2003.

However I have not been able to programatically set the width of a template
column programatically

Here is the code that I have used so far
Private Class DataGridTemplate
Implements ITemplate
Dim templateType As ListItemType
Dim columnName As String
Sub New(ByVal type As ListItemType, ByVal ColName As String)
templateType = type
columnName = ColName
End Sub

Sub InstantiateIn(ByVal container As Control) _
Implements ITemplate.InstantiateIn
Dim lc As New Literal
Dim txt As New TextBox
Select Case templateType
Case ListItemType.Header
lc.Text = "<B>" & columnName & "</B>"
container.Controls.Add(lc)
Case ListItemType.Item
txt.ID = columnName
txt.Font.Name = "Verdana"
txt.Font.Size = FontUnit.XXSmall
txt.Font.Bold = True
txt.Columns = 10
txt.Width = Unit.Percentage(5)
container.Controls.Add(txt)
End Select
End Sub
End Class

And here is the code that calls the class
Dim columnlist As New SortedList
columnlist.Clear()
Dim row As DataRow
For Each row In ds.Tables("AllLevel3AttributesForLevel4").Rows
Dim tempcol As New TemplateColumn
tempcol.HeaderTemplate = New
DataGridTemplate(ListItemType.Header, row("AttributeCode").ToString)
tempcol.ItemTemplate = New DataGridTemplate(ListItemType.Item,
row("AttributeCode").ToString)
grdKeysGenerated.Columns.Add(tempcol)
columnlist.Add(row("AttributeId").ToString,
row("AttributeCode").ToString)
Next
' Save into session the list of columns (attributes) for this level 4
Session("ColumnList") = columnlist
If ds.Tables("AllDatakeys").Rows.Count > 0 Then
With grdKeysGenerated
.DataSource = ds.Tables("AllDataKeys")
.DataBind()
End With
End If

Is there any way to programatically set the new columns i have created to
have widths of 5% (or lets say 50px)?

Thanks in advance

Corey

Jul 21 '05 #1
0 1644

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

Similar topics

3
by: frank | last post by:
How do I set the column width of a column in a DataGrid programatically (in ASP.NET web pages)? I understand I may have to use DataGridTableStyle, but I can't get this to work with web pages. ...
2
by: Tim Nelson | last post by:
I thought there should be simple way of setting the column width in the a DataGrid. I've set up a table style (properties tab) that lengthen the columns, but I can't seem to bind this table style...
0
by: Dan Hartshorn | last post by:
VS.NET 2003, C#, Windows Server 2003. I have a datagrid and I want the last column to be either an EditCommandColumn or a template column, depending on a value I have. The value changes for each...
2
by: Yama | last post by:
Hi, How can I make it resizable? For example: <pre> <!-- datagrid Header --> <table class="TableHeader" id="tblHeader" border="1" runat="server">
2
by: Jaime Lucci | last post by:
Hi, how've you been? How can I do to set the column width of a datagrid to fix the width of the text in each column? Thanks. Jaime Lucci jaimelucci@hotmail.com
0
by: CoreyMas | last post by:
Hello Everyone, I have been successful in creating a template column programatically using the examples provided in VS 2003. However I have not been able to programatically set the width of a...
2
by: Charleees | last post by:
Hi all, I have a DataGrid with Template Columns..... There are LAbels,Linkbuttons in the Single Row.. I have to set the Constant Column width for those Template Columns in Grid... Wat...
31
by: Sarita | last post by:
Hello, this might sound stupid, but I got a really nice homepage template which unfortunately is a 3-Column Fixed Width CSS format. Now I don't have any content for the right column and would...
0
by: GMartin | last post by:
I have a pop-up form with a three columned Grid that has checkboxes in a Template Column in the first/left-most column. (The form is to allow users to select "Members" of a group, where they check...
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
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...
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...

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.