473,405 Members | 2,287 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,405 software developers and data experts.

Column Width in a Gridview

How can I change the column width in a gridview filled with a dataset? I
can't get TableStyle to work. Has anyone any sample code, please?

Thanks,
Helen

PS. I am creating a web page in ASP.Net 2.0 using C#.

This is my code so far:

SqlConnection cn; // Connection to the SQL database
SqlDataAdapter da;
DataSet ds;

cn = new SqlConnection();
da=new SqlDataAdapter("Select * From Patient",cn);
ds = new DataSet();

OpenConnection(cn); // Connects to the database
da.Fill(ds,"PatientTable");
dgPatients.DataSource = ds.Tables["PatientTable"];
dgPatients.DataBind();
cn.Close();
Feb 12 '07 #1
1 1738

"Helen Trim" <He*******@discussions.microsoft.comwrote in message
news:E2**********************************@microsof t.com...
How can I change the column width in a gridview filled with a dataset? I
can't get TableStyle to work. Has anyone any sample code, please?

Thanks,
Helen

PS. I am creating a web page in ASP.Net 2.0 using C#.
Thus your question belongs in the ASP.NET group, and possibly the C# group,
but this is the Visual C++ group.
>
This is my code so far:

SqlConnection cn; // Connection to the SQL database
SqlDataAdapter da;
DataSet ds;

cn = new SqlConnection();
da=new SqlDataAdapter("Select * From Patient",cn);
ds = new DataSet();

OpenConnection(cn); // Connects to the database
da.Fill(ds,"PatientTable");
dgPatients.DataSource = ds.Tables["PatientTable"];
dgPatients.DataBind();
cn.Close();


Feb 12 '07 #2

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

Similar topics

5
by: Steve Bugden | last post by:
Hi, I would like to set the column widths in the ASP.NET GridView control at runtime I have tried the following: http://msdn2.microsoft.com/en-us/library/ms178296.aspx Which uses the...
1
by: msch-prv | last post by:
I have difficulties adjusting the column width of a gridview control. The column width changes appear in the design grid, but at run-time the width changes back to what I presume are the grid's...
4
by: Chuck | last post by:
I'm setting the column with for a gridview (25+- columns) and have paging turned on. When the gridview is first displayed, the column widths are all set to the default. But after paging to...
0
by: landesjoe | last post by:
Hi, here's my problem in short: Text boxes in gridview don't seem to hold their value if the column's .Visible property is changed back and forth. I've got a form with a gridview populated from...
6
by: =?Utf-8?B?TWlrZSBQYXJyaXM=?= | last post by:
I am trying to set the width of one of the columns of an asp.net 2.0 Gridview control. I am using a line - MyGridview.Columns.ItemStyle.Width = Unit.Percentage(40); The problem is that there...
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...
3
by: =?Utf-8?B?SmVu?= | last post by:
I would like to set the width on 2 columns of a asp.net gridview control, but I'm having trouble making this work. Here is the code I use to create the gridview: 'Create a new data table...
5
by: mohaaron | last post by:
OK, I have now gone through lots of posts, and there are lots, looking for a anwer as to why I can't set the width of the columns in my gridview. So far I have tried the following methods to set...
4
by: Yin99 | last post by:
I have a Gridview binding to a DataTable source. I'd like to set the column with of the second column. I cannot do this apparently because when AutoGenerateColumns=true, they do not appear in the...
0
by: progman417 | last post by:
I have a gridview with a dropdown list in an EditItemTemplate. I haven't set a width for the columns, so that they dynamically size according to the data displayed. When it goes into edit...
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: 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:
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
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.