473,406 Members | 2,336 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,406 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 1645

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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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:
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...

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.