Since I am new with working with C#asp.net web controls 2010, I have the following question to ask about the gridview control:
1. Since there a way to change the orientation of the gridview control. Instead of being horizontal orientation, I would like the the gridview control to be vertical display? This column names would go down the left side of the grid? If this is possible, what do I need to do change the orientation?
2. I want to embeded dropdown list controls in different cells. Is there a way you recommend I accomplish this task? Is there some like 'BulkEditGridView' for dropdown list controls?
Loading
Datta KharadPosted Nov 3, 2011, 1:51 AM
This code help you for displaying column names in left side of gridview.
private void BindData()
{
DataSet ds = this.GetDetail(); // Some DataSet
DataSet new_ds = FlipDataSet(ds); // Flip the DataSet
DataView my_DataView = new_ds.Tables[0].DefaultView;
this.my_DataGrid.DataSource = my_DataView;
this.my_DataGrid.DataBind();
}
public DataSet FlipDataSet(DataSet my_DataSet)
{
DataSet ds = new DataSet();
foreach(DataTable dt in my_DataSet.Tables)
{
DataTable table = new DataTable();
for(int i=0; i<=dt.Rows.Count; i++)
{
table.Columns.Add(Convert.ToString(i));
}
DataRow r;
for(int k=0; k
r = table.NewRow();
r[0] = dt.Columns[k].ToString();
for(int j=1; j<=dt.Rows.Count; j++)
r[j] = dt.Rows[j-1][k];
}
table.Rows.Add(r);
}
ds.Tables.Add(table);
}
return ds;
}
If you got correct solution then mark as Accepted Answer.