Hi friends , I have a requirement on gridview, i have a datatable for that i was assigning the column names manually and also adding the data to datatable. After that i am set the datatable vertically and bind to the gridview.
var tbl = dt;
var swappedTable = new DataTable();
if (tbl.Rows.Count > 0)
{
swappedTable.Columns.Add("Name");
for (int i = 0; i <= tbl.Rows.Count-1; i++)
{
DataRow dx = tbl.Rows[i];
var x = dx.ItemArray;
swappedTable.Columns.Add(x[3].ToString());
}
for (int col = 0; col < tbl.Columns.Count; col++)
{
var r = swappedTable.NewRow();
r[0] = tbl.Columns[col].ToString();
for (int j = 1; j <= tbl.Rows.Count; j++)
r[j] = tbl.Rows[j - 1][col];
swappedTable.Rows.Add(r);
}
gvwHDMonitor.DataSource = swappedTable;
gvwHDMonitor.DataBind();
Example :
Name ......................
IICSS21
Operating System ............. Microsoft Windows 7 Professional
Version .............. 6.1.7601
Manufacturer ............. Microsoft Corporation
Computer Name ............. IICSS21
Windows Directory ............. C:\Windows
Serial Number ............. 00371-OEM-9203635-37779
ComputerManufacturer Name ............. Dell Inc.
Computer Model ............. OptiPlex 990
System Type ............. x64-based PC
here : Operationg system, Version like these are the columns
Microsoft Windows 7 Professional,6.1.760l these are the first row in datatable and same time other records also added dynamically to datatable as columns.
Here dynamically added the columns to datatable.
Problem is i want to increase the column width for dynamically added columns.
How can do this problem.
Please any one help me.