Hi Joey,
In addition to Saravana, Alvin's suggestion on do the rotate at the
datasource level( switch the datas in the DataSet), here are my suggestions;
As for your condition,you're not only want to display horizentally, but
also perform the horizental mode at edit mode, so I think the DataGrid web
server control is not very suitable. I'd recommend you try the DataList
control
The DataList Control has a "RepeatDirection" property which is used to
speicify the direction of the repeated items in the DataList, we can assign
the "RepeatDirection.Horizontal" as its value so as to let the items
repeated horizentally. Also, we need to customize the ItemTemplate and
EditTemplate and manually add the CommandButtons in DataList. For detailed
reference , you can view the following link in MSDN:
#DataList.RepeatDirection Property
http://msdn.microsoft.com/library/en-us/cpref/html/frlrfsystemwebuiwebcontro
lsdatalistclassrepeatdirectiontopic.asp?frame=true
To make it clearly, here is a simple demo page, you may have a look :
==================aspx page======================
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>DataList</title>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="
http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<table width="100%" align="center">
<tr>
<td><asp:datalist id="dlMain" runat="server"
RepeatDirection="Horizontal">
<HeaderTemplate>
<table align="center" width="100%">
<tr>
</HeaderTemplate>
<FooterTemplate>
</tr>
</table>
</FooterTemplate>
<ItemTemplate>
<td>
<table>
<tr>
<td><%# DataBinder.Eval(Container.DataItem,"index") %></td>
</tr>
<tr>
<td><%# DataBinder.Eval(Container.DataItem,"name") %></td>
</tr>
<tr>
<td><%# DataBinder.Eval(Container.DataItem,"email") %></td>
</tr>
<tr>
<td><asp:Button ID="btnEdit" Runat="server" Text="Edit"
CommandName="Edit" CommandArgument='<%# Container.ItemIndex
%>'></asp:Button></td>
</tr>
</table>
</td>
</ItemTemplate>
<EditItemTemplate>
<td>
<table>
<tr>
<td><asp:TextBox ID="txtIndex" Runat="server" Text='<%#
DataBinder.Eval(Container.DataItem,"index") %>'></asp:TextBox></td>
</tr>
<tr>
<td><asp:TextBox ID="txtName" Runat="server" Text='<%#
DataBinder.Eval(Container.DataItem,"name") %>'></asp:TextBox></td>
</tr>
<tr>
<td><asp:TextBox ID="txtEmail" Runat="server" Text='<%#
DataBinder.Eval(Container.DataItem,"email") %>'></asp:TextBox></td>
</tr>
<tr>
<td>
<asp:Button ID="btnUpdate" Runat="server" Text="Update"
CommandName="Update" CommandArgument='<%# Container.ItemIndex %>'>
</asp:Button>
<asp:Button ID="btnCancel" Runat="server" Text="Cancel"
CommandName="Cancel" CommandArgument='<%# Container.ItemIndex %>'>
</asp:Button>
</td>
</tr>
</table>
</td>
</EditItemTemplate>
</asp

ataList></TD></TR>
<tr>
<td></td>
</tr>
</TABLE></form>
</body>
</HTML>
================code behind page classs============
public class DataList : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DataList dlMain;
private void Page_Load(object sender, System.EventArgs e)
{
if(!IsPostBack)
{
Bind_Data();
}
}
private void Bind_Data()
{
DataTable tb = new DataTable("user");
tb.Columns.Add("index",typeof(int));
tb.Columns.Add("name",typeof(string));
tb.Columns.Add("email",typeof(string));
DataRow dr = null;
for(int i=1;i<=6;i++)
{
dr = tb.NewRow();
dr["index"] = i;
dr["name"] = "Name" + i;
dr["email"] = "User" + i + "@test.com";
tb.Rows.Add(dr);
}
dlMain.DataSource = tb;
dlMain.DataBind();
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.dlMain.CancelCommand += new
System.Web.UI.WebControls.DataListCommandEventHandler(this.dlMain_CancelComm
and);
this.dlMain.EditCommand += new
System.Web.UI.WebControls.DataListCommandEventHandler(this.dlMain_EditComman
d);
this.dlMain.UpdateCommand += new
System.Web.UI.WebControls.DataListCommandEventHandler(this.dlMain_UpdateComm
and);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void dlMain_EditCommand(object source,
System.Web.UI.WebControls.DataListCommandEventArgs e)
{
dlMain.EditItemIndex = e.Item.ItemIndex;
Bind_Data();
}
private void dlMain_UpdateCommand(object source,
System.Web.UI.WebControls.DataListCommandEventArgs e)
{
dlMain.EditItemIndex = -1;
Bind_Data();
}
private void dlMain_CancelCommand(object source,
System.Web.UI.WebControls.DataListCommandEventArgs e)
{
dlMain.EditItemIndex = -1;
Bind_Data();
}
}
====================================================
Hope these helps. Thanks.
Regards,
Steven Cheng
Microsoft Online Support
Get Secure!
www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx