|
-
Oct 7th, 2002, 12:47 AM
#1
Thread Starter
Hyperactive Member
DataGrid- Columns Width
hi
Can anyone give me a lines of code to display the datagrid in specified column width. I mean the columns of datagrid shold be arriged by the developer.
Thanks
-
Oct 7th, 2002, 07:42 AM
#2
Addicted Member
Width
PHP Code:
'First you have to give the datagrid a percentage to work form
dg.Width = Unit.Percentage(300)
'then in your code you can tell the datagrid what field you want to change the width of.
dg.Columns(4).ItemStyle.Width = Unit.Percentage(5)
The important thing to understand is: The original width can be greater than 100%. I have found no documentation to validate this, just what I have come up with on my own.
-
Oct 8th, 2002, 12:42 AM
#3
Thread Starter
Hyperactive Member
Hi Abashai
What ever u hv given is correct for Writing the code in OnLoad of Event. But I need to write the code Where i have the line of code for DataGrid It must be something like
Code:
<asp:datagrid id="DataGrid1" runat="server" backcolor="#EEEEEE" top="20px" Height="60px" Width="487" PageSize="20" AutoGenerateColumns="False" showHeader="false">
<Columns>
<asp:BoundColumn DataField="projCode" ReadOnly="True"> </asp:BoundColumn>
...
...
[color=red]
< Column1... Fixedwith="100" -- Someting like this
( I am just imaging the code like this) [/color=red]
...
</asp:Grid>
-
Oct 8th, 2002, 06:14 AM
#4
Addicted Member
Reply
I see what you are trying to do. I think you code has to post back to the server, so the page would have to load again.
Each time the form loads you have to recreate the column.
You might have code similar to this
PHP Code:
if not me.ispostback
Dim Company As New BoundColumn()
Company.DataField = "cCompanyName"
Company.HeaderText = "Company Name"
Company.SortExpression = "CompanyName"
dgCustomers.Columns.Add(Company)
dg.Columns(4).ItemStyle.Width = Unit.Percentage(5
end if
If you are creating the datagrid at runtime then I would use something similar to the code above.
-
Oct 8th, 2002, 08:13 AM
#5
Thread Starter
Hyperactive Member
I found the Solution..
We Need to add the Line of COde like
<ItemTemplate Width="120">
Thanks for tryails
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|