How to dispaly Data in gridview From Database with example.
How to dispaly Data in gridview From Database with simple example.
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Pankaj Kumar198 reputationPosted Aug 6, 2013, 9:58 AM EDT
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();
}
}
sandy kumar3 reputationPosted Aug 7, 2013, 6:52 AM EDT
waqas memon141 reputationPosted Aug 7, 2013, 7:49 AM EDT
http://www.codingresolved.com/discussion/894/how-to-correctly-highlight-gridview-rows-on-mouseover-in-asp-net/p1