How to dispaly Data in gridview From Database with example.
How to dispaly Data in gridview From Database with simple example.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Pankaj KumarPosted Aug 6, 2013, 1:58 PM
take one button control and one gridview control . then write the code in button event
see below example.
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.Data.SqlClient;
public partial class GridViewControl1 : System.Web.UI.Page
{
SqlConnection con;
SqlDataAdapter da;
DataSet ds;
protected void Button1_Click(object sender, EventArgs e)
{
con = new SqlConnection("user id=sa;password=sa;database=C#Prac;Data Source=.");
ds = new DataSet();
da = new SqlDataAdapter("SELECT * FROM Dept", con);
da.Fill(ds, "Stud");
GridView1.DataSource = ds.Tables[0];
GridView1.DataBind();
}
}
waqas memonPosted Aug 7, 2013, 11:49 AM
http://www.codingresolved.com/discussion/894/how-to-correctly-highlight-gridview-rows-on-mouseover-in-asp-net/p1
sandy kumarPosted Aug 7, 2013, 10:52 AM