473,508 Members | 1,998 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Unable to Set DataGrid Column Width in ASP.NET

VijaySofist
107 New Member
Hi All!

I am using ASP.Net with Vb Coding in Windows XP Machine. I am Using a DataGrid and I am Passing a DataBase to this DataGrid. Data are get filled from the DataBase. Now I want to Set the First Column Width to Some pixels (Ex: 150 pixels).

I am using the following code:

Expand|Select|Wrap|Line Numbers
  1. Datagrid1.Columns(0).ItemStyle.Width.Pixel(150)
But it does n't works.

Thanks in Advance

With Regards
Vijay. R
Dec 28 '07 #1
2 1263
nateraaaa
663 Recognized Expert Contributor
What is the AutoGenerateColumns property of your datagrid set to?

If you want to control the width of your columns it should be set to false.

Nathan
Dec 28 '07 #2
VijaySofist
107 New Member
What is the AutoGenerateColumns property of your datagrid set to?

If you want to control the width of your columns it should be set to false.

Nathan

Hi!

First of all Thanks for your Reply.

My Datagrid's AutoGenerateColumns property = True

If I set it to False Then then DataBase Values are not been populated into it.
What Should I do in this situation
My Code is
Expand|Select|Wrap|Line Numbers
  1.   Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  2.         sqlcon.ConnectionString = "server=2k6;database=orgsat;UID=sa;pwd=gopalan;"
  3.         sqlcon.Open()
  4.         sqlcmd.CommandText = "Select Date=convert(varchar(10),ndate,105),Topic=substring(Ntopic,1,15),UserId from satuserpost union select Date=convert(varchar(10),rdate,105),Topic=substring(rmessage,1,15),UserId=ruserid from SatPostreply"
  5.         sqlcmd.CommandType = Data.CommandType.Text
  6.         sqlcmd.Connection = sqlcon
  7.         sdrdata = sqlcmd.ExecuteReader
  8.         DataGrid1.DataSource = sdrdata
  9.         DataGrid1.DataBind()
  10.         DataGrid1.Columns(1).ItemStyle.Width.Pixel(1)
  11.         sqlcon.Close()
  12.     End Sub
  13.  



Thanks and Regards
Vijay. R
Dec 29 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

5
3358
by: Prateek | last post by:
Hi, How can I change the width of a column in datagrid control? TIA Prateek
9
3929
by: web1110 | last post by:
Hi y'all, I have resized the columns in a DataGrid and I want to set the width of the DataGrid to fit the columns. Just summing the column widths is too short due to the grid and gray row...
3
4224
by: Richard | last post by:
I have a requirement to put a GDI style circle or rectangle border around the selected row of a datagrid/ It will overlap into the row above and below the selected row. Doing this in a the OnPaint...
2
6374
by: CSL | last post by:
I am using the DataGrid in a Windows Application, how can I adjust the widths of each column individually.
4
1818
by: Steve | last post by:
I am fairly new to VB.NET, and I am rewriting an application I wrote a while back, also in VB.NET. I aplied some new things I learned. Anyway, here is my problem....... I have a custom DataGrid...
17
7413
by: Mike Fellows | last post by:
im trying (unsucessfully) to add a checkbox column to my datagrid i basically have a datagrid that im populating from a dataset Me.DataGrid1.DataSource = ds.Tables(0) the datagrid then has 5...
6
2735
by: Agnes | last post by:
I understand it is impossible, but still curious to know "Can I freeze several column in the datagrid, the user can only scroll the first 3 columns (not verical), for the rest of the coulumn, it is...
2
10378
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...
2
1764
by: cj | last post by:
I was looking over some of my 2003 code today (see below) that loads a foxpro table via oledb connection. I used a sub "autosizecolumns" I found on the web but I never quite understood why they...
2
6562
by: =?Utf-8?B?Y3JlYXZlczA2MjI=?= | last post by:
I have a nested datagrid in a xaml file, the parent datagrid loads the vendor information and the details loads the documents for that vendor in a datagrid. Everything is working fine until I click...
0
7227
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
7127
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
7391
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...
1
7054
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5633
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,...
0
3204
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3188
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1564
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
424
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.