Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > DataGrid Column widths not changing - help!!!

Reply
Thread Tools

DataGrid Column widths not changing - help!!!

 
 
Andre Ranieri
Guest
Posts: n/a
 
      09-29-2003

I forgot to ask, but are there any properties and methods
that would allow me to customize the output formatting of
the bound columns? For example, I'd like the date
completed to show in short date format, the balance to
show as a decimal/currency.

Thanks,

Andre






I'm trying to programmatically create columns for a
datagrid and set
their width. The "Services" field especially has a fairly
long text
value, I'd like to make it wider than the default.

I've scoured the MSDN library and the newsgroups, and have
tried
setting the Itemstyle.Width of the bound column as well as
dgRecentServices.Columns
[1].ItemStyle.Width = Unit.Pixel(400);.

Would someone please point me in the right direction? I'm
not sure
what I'm doing wrong.

Thanks,

Andre




private void dgFillRecent()
{

BoundColumn bc = new BoundColumn();
bc.HeaderText = "Invoice";
bc.DataField = "ServiceID";
bc.ItemStyle.Width = Unit.Pixel
(500);
dgRecentServices.Columns.Add(bc);

bc = new BoundColumn();
bc.HeaderText = "Service";
bc.DataField = "Service";
dgRecentServices.Columns.Add(bc);

bc = new BoundColumn();
bc.HeaderText = "Status";
bc.DataField = "Status";
dgRecentServices.Columns.Add(bc);

bc = new BoundColumn();
bc.DataField = "DateCompleted";
bc.HeaderText = "Date ";
dgRecentServices.Columns.Add(bc);

bc = new BoundColumn();
bc.DataField = "AmountCompleted";
bc.HeaderText = "Amount";
dgRecentServices.Columns.Add(bc);

bc = new BoundColumn();
bc.DataField = "Balance";
bc.HeaderText = "Balance";
dgRecentServices.Columns.Add(bc);


dgRecentServices.Columns
[1].ItemStyle.Width = Unit.Pixel(400);

}





private void RecentServices(String sAccountKey,
SqlConnection cn)
{
DateTime datNow = DateTime.Now;

dgFillRecent();

string sSQL = "SELECT TOP 7 Service,
Status, PreNotifyType, " +
"DateScheduled, ServiceID,
DateCompleted, AmountCompleted, Balance
" +
"FROM dbo.tblMainServices " +
"WHERE (AccountKey = " +
sAccountKey + ") AND (DateCompleted < '" +
datNow + "') " +
"ORDER BY DateCompleted DESC;";
SqlDataAdapter da = new
SqlDataAdapter();
da.SelectCommand = new SqlCommand
(sSQL, cn);
DataSet ds = new DataSet();

da.Fill(ds, "LastServices");
DataTable LastServices;
LastServices = ds.Tables
["LastServices]"];
string sService, sStatus,
sPreNotifyType, sServiceID;
DateTime datDateScheduled,
datDateCompleted;
decimal decSaleAmount, decBalance;


dgRecentServices.DataSource=ds.Tables
["LastServices"];

DataView source = new DataView
(ds.Tables[0]);
dgRecentServices.DataSource =
source ;
dgRecentServices.DataBind();
..


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Column Widths...NOT a DATAGRID..Just A table vpravin ASP .Net 5 06-14-2007 05:16 PM
Forced Column Widths in a DataGrid? =?Utf-8?B?QWxleCBNYWdoZW4=?= ASP .Net 3 06-20-2006 12:16 PM
Datagrid column widths in edit mode =?Utf-8?B?RWxtZXI=?= ASP .Net 4 04-19-2005 12:25 AM
datagrid column widths - remember after postback wh1974 ASP .Net 1 01-11-2005 04:13 PM
DataGrid Column widths not changing - help!!! Andre ASP .Net Web Controls 0 09-29-2003 06:32 AM



Advertisments