Displaying vertical rows in a GridView [Resolved]

Posted by Jitenkumar under ASP.NET on 7/31/2013 | Points: 10 | Views : 14747 | Status : [Member] | Replies : 4
How to displaying vertical rows in a GridView




Responses

Posted by: Satyapriyanayak on: 7/31/2013 [Member] [MVP] Silver | Points: 50

Up
0
Down

Resolved
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="FlipGridView.aspx.cs" Inherits="XmlPostData" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" runat="server" ShowHeader="false" AllowSorting="true">
</asp:GridView>
</div>
</form>
</body>
</html>



using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Net;
using System.Text;
using System.IO;

public partial class FlipGridView:System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

GridView1.DataSource = FlipDataSet(c());
GridView1.DataBind();

}

public DataSet c()
{
DataSet ds = new DataSet();
DataTable dt = new DataTable("Company");
DataRow dr;
dt.Columns.Add(new DataColumn("accountNo", typeof(Int32)));
dt.Columns.Add(new DataColumn("CompanyName", typeof(string)));
dt.Columns.Add(new DataColumn("Address", typeof(string)));
for (int i = 0; i <= 10; i++)
{
dr = dt.NewRow();
dr[0] = i;
dr[1] = "Company" + i + Environment.NewLine + "Title" + i;
dr[2] = "Address" + i + Environment.NewLine + "Title" + i;
dt.Rows.Add(dr);
}
ds.Tables.Add(dt);
return ds;
}
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 = null;
for (int k = 0; k < dt.Columns.Count; 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;
}
}




http://aspdotnetcodebook.blogspot.com/2008/04/displaying-vertical-rows-in-gridview.html
http://www.codeproject.com/KB/database/Vertical_rows_in_Datagrid.aspx

If this post helps you mark it as answer
Thanks

Jitenkumar, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ssj_Kumar on: 7/31/2013 [Member] Starter | Points: 50

Up
0
Down

Resolved
one more article
http://www.codeproject.com/Articles/5030/Displaying-vertical-rows-in-a-DataGrid

Regards,
Jayakumar Selvakani

Jitenkumar, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: aswinialuri-19361 on: 7/31/2013 [Member] Starter | Points: 50

Up
0
Down

Resolved
hi,
refer this link it might be helpful to you
http://www.codeproject.com/Articles/19313/Displaying-Vertical-Rows-in-DataGrid-View
http://www.codeproject.com/Questions/265612/How-to-display-Grid-Values-in-Vertical-Row-instead
http://forums.asp.net/t/1130758.aspx

Mark as Answer if it helps you
Thanks&Regards
Aswini Aluri

Jitenkumar, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ssj_Kumar on: 7/31/2013 [Member] Starter | Points: 25

Up
0
Down
Below link explain how to achieve vertical rows
http://www.codeproject.com/Articles/19313/Displaying-Vertical-Rows-in-DataGrid-View

Regards,
Jayakumar Selvakani

Jitenkumar, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response