Display Gridview in horizontal mode..

Posted by Shameer.Ali87 under ASP.NET on 5/4/2013 | Points: 10 | Views : 4482 | Status : [Member] | Replies : 2
hi friends,

i am having two columns one is sname, smarks by default gridview is displaying data vertically but i want to show horizontally like this

sname shankar kartik
smarks 10 20

shameer ali shaik


Responses

Posted by: Satyapriyanayak on: 5/4/2013 [Member] [MVP] Silver | Points: 25

Up
0
Down
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Gridview._Default" %>

<!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="g1" Runat="Server">
</asp:GridView>
</div>
</form>
</body>
</html>




using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
namespace Gridview
{
public partial class _Default : System.Web.UI.Page
{
string connStr = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
SqlCommand com;
SqlDataAdapter sqlda;
DataSet ds;
string str;

protected void Page_Load(object sender, EventArgs e)
{
bindgrid();
}
private void bindgrid()
{
SqlConnection con = new SqlConnection(connStr);
con.Open();
str = "select * from students";
com = new SqlCommand(str, con);
sqlda = new SqlDataAdapter(com);
ds = new DataSet();
sqlda.Fill(ds, "students");
g1.DataMember = "students";
g1.DataSource = ds;
g1.DataBind();
con.Close();


}


}
}


If this post helps you mark it as answer
Thanks

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

Posted by: aswinialuri-19361 on: 5/4/2013 [Member] Starter | Points: 25

Up
0
Down
allow paging=true; page size=2;
it will work



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

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

Login to post response