Hi:<BR><BR>I had to display a DataTable horizontally i.e the Columns of datatable had to shown as rows and the rows as columns. For that I read the original Datatable and created another datatable with columns changed to rows and rows to columns. <BR><BR>private void Page_Load(object sender, System.EventArgs e)<BR>{<BR> // Put user code to initialize the page here<BR> sqlConn.Open(); <BR> if (IsPostBack == false) <BR> { <BR> sqlCmd.CommandText = "SELECT Employeeid, FirstName +&#039; &#039;+ LastName As Name, BirthDate, HireDate FROM Employees"; <BR> sqlCmd.Connection = sqlConn; <BR> sqlDA.SelectCommand = sqlCmd; <BR> sqlDA.Fill(sqlDS, "Employees");<BR> <BR> }<BR> CreateDataTable();<BR>}<BR><BR>private void CreateDataTable() <BR>{ <BR>DataTable dtTest = new DataTable(); <BR>int i, j; <BR>string ColName; <BR>DataRow drTest; <BR>ArrayList al = new ArrayList();<BR>//retrieving all column names from the DataTable into an arryalist<BR>foreach (System.Data.DataColumn dc in sqlDS.Tables[0].Columns) <BR>{ <BR> al.Add(dc.ColumnName); <BR>}<BR><BR><BR>//adding columns to the datatable = DataTable.Rows.count + 1(for col names)<BR>for (i = 0; i &#060;= sqlDS.Tables[0].Rows.Count; i++) <BR>{ <BR> DataColumn dcTest = new DataColumn(); <BR> dcTest.DataType = System.Type.GetType("System.Object"); <BR> ColName = "Col" + i; <BR> <BR> dcTest.ColumnName = ColName; <BR> dtTest.Columns.Add(dcTest); <BR>}<BR><BR>//adding rows and the data to the datatable<BR>for (j = 0; j &#060;= sqlDS.Tables[0].Columns.Count - 1; j++) <BR>{ <BR> drTest = dtTest.NewRow(); <BR> <BR> //if( i ==0)<BR> drTest[0] = al[j];<BR><BR> for (i = 1; i &#060; dtTest.Columns.Count ; i++) <BR> { <BR> <BR> drTest[i] = sqlDS.Tables[0].Rows[i-1][j];<BR> if(sqlDS.Tables[0].Columns[j].ColumnName.Equals("Name"))<BR> {<BR> drTest[i] = ChangeToLink(drTest[i].ToString(),i-1);<BR> }<BR> if(sqlDS.Tables[0].Columns[j].ColumnName.Equals("Employeeid"))<BR> { <BR> alID.Add(sqlDS.Tables[0].Rows[i-1][j]);<BR> }<BR><BR> <BR> } <BR> dtTest.Rows.Add(drTest); <BR> <BR> } <BR> this.sqlDS.Tables.Add(dtTest);<BR> Session["IDList"] = alID;<BR> <BR>}<BR><BR>So the new datatable is added to the DataSet.<BR>Now , i had to show the Name Row (previously Column) as Hyperlink. For that I added Link Buttons which is done by calling method ChangeToLink() in the aboove code..if u can&#039;t locate it, look something like this in the above code<BR><BR>if(sqlDS.Tables[0].Columns[j].ColumnName.Equals("Name"))<BR> {<BR> drTest[i] = ChangeToLink(drTest[i].ToString(),i-1);<BR> }<BR><BR>Now the code for ChangeToLink() methid is as follows where Link Button are created and are assigned the Command Event LinkButtonClick()<BR><BR>private string ChangeToLink(string str,int i)<BR>{<BR> <BR> StringBuilder strLink = new StringBuilder(512);<BR> StringWriter sw = new StringWriter(strLink);<BR> System.Web.UI.HtmlTextWriter htmlTW = new HtmlTextWriter(sw);<BR> System.Web.UI.WebControls.LinkButton lb = new LinkButton();<BR> lb.Text = str;<BR> lb.CommandArgument = i.ToString();<BR> lb.ID = "LinkButton"+i;<BR> lb.Attributes.Add("HREF", "Exercise2_2.aspx");<BR> lb.Command += new <BR><BR>System.Web.UI.WebControls.CommandEventHand ler(LinkButtonClick);<BR> lb.RenderControl(htmlTW);<BR> return strLink.ToString();<BR> <BR>}<BR><BR>Here is the Command Event for the LinkButton:<BR><BR>private void LinkButtonClick(object sender, <BR><BR>System.Web.UI.WebControls.CommandEventAr gs e)<BR>{<BR> string btnindex = e.CommandArgument.ToString();<BR> Session["ButtonIndex"] = btnindex;<BR> Server.Transfer("Exercise2_2.aspx");<BR><BR>}<BR>< BR>Now the new tranposed datatable is assigned as the DataSource for a dynamically <BR><BR>generated datagrid.<BR><BR>this.DataGrid2 = new DataGrid();<BR>this.DataGrid2.AutoGenerateColumns= false;<BR>this.DataGrid2.DataSource = this.sqlDS.Tables[1].DefaultView;<BR> <BR>foreach(DataColumn c in sqlDS.Tables[1].Columns)<BR>{ <BR> DataGrid2.Columns.Add(CreateBoundColumn(c));<BR>}< BR> this.DataGrid2.ShowHeader = false;<BR> this.DataGrid2.DataBind();<BR> this.DataGrid2.EnableViewState = true;<BR> PlaceHolder1.Controls.Add(DataGrid2);<BR><BR><BR>p rivate BoundColumn CreateBoundColumn(DataColumn c)<BR>{<BR> BoundColumn column = new BoundColumn();<BR> column.DataField = c.ColumnName; <BR> return column;<BR>}<BR><BR>the good thing is that datagrid is displayed the way i want it with Name row as Link Buttons. However when i click on the link buttons in the Name row, the Command event i.e LinkButtonClick() event handler not called and hence the index number of the Link Button is not stored in the session.<BR><BR>Can anyone tell me why? I have been struggling with it for a long time..any help will be appreciated.<BR>