size of a datacolumn

  • Thread starter Thread starter Nikhil Patel
  • Start date Start date
N

Nikhil Patel

Hi all,
How can I get the size of a Column of a DataSet's Table? The DataSet is
filled with SQL Server data. The columns are of varchar type. When I display
this data in my ASP.Net form, I would like to set the MaxLength property of
the TextBox controls to the size of the DataColumns.

Thanks...
-Nikhil
 
try this ou

in the Datagrid_ItemDataBound metho

e.Item.Width=System.Web.UI.WebControls.Unit.Pixel(e.Item.Cells[index].Text.Length)

sample cod
private void DatagridName_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e


//e.Item.Cells[index] index -->would be the column which you want to change the length
e.Item.Width=System.Web.UI.WebControls.Unit.Pixel(e.Item.Cells[index].Text.Length)


Regards
Kris


----- Nikhil Patel wrote: ----

Hi all
How can I get the size of a Column of a DataSet's Table? The DataSet i
filled with SQL Server data. The columns are of varchar type. When I displa
this data in my ASP.Net form, I would like to set the MaxLength property o
the TextBox controls to the size of the DataColumns

Thanks..
-Nikhi
 
Thanks kris. But I don't display data in a grid. I display it in textboxes.

kris said:
try this out

in the Datagrid_ItemDataBound method

e.Item.Width=System.Web.UI.WebControls.Unit.Pixel(e.Item.Cells[index].Text.L
ength);

sample code
private void DatagridName_ItemDataBound(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{

//e.Item.Cells[index] index -->would be the column which you want to change the length
e.Item.Width=System.Web.UI.WebControls.Unit.Pixel(e.Item.Cells[index].Text.L
ength);
}

Regards,
Kris.


----- Nikhil Patel wrote: -----

Hi all,
How can I get the size of a Column of a DataSet's Table? The DataSet is
filled with SQL Server data. The columns are of varchar type. When I display
this data in my ASP.Net form, I would like to set the MaxLength property of
the TextBox controls to the size of the DataColumns.

Thanks...
-Nikhil
 
Back
Top