Click here to Skip to main content
15,908,455 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
how to view the table using data grid view..... pls tell me
Posted
Comments
Pandya Anil 1-Nov-11 7:35am    
add some more description to your question... what type of table you want to view, html or database table ?
RAMALINGAM.K 1-Nov-11 7:50am    
in student details...........using sql data base.....for example i using student details managment...


Hi use this to dispaly the student records in gridview....

Design code

<asp:gridview id="GridView1" runat="server" xmlns:asp="#unknown">
            </asp:gridview>


Code behind code

    protected void Page_Load(object sender, EventArgs e)
    {

SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["Connection String name as in web Config file"].ConnectionString);
        if (!Page.IsPostBack)
        {
            con.Open();
            SqlCommand cmd = new SqlCommand("Your sql query here", con);
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataSet ds = new DataSet();
            da.Fill(ds);
            GridView1.DataSource = ds;
            GridView1.DataBind();
            con.Close();
        }
    }
 
Share this answer
 
Comments
catamit 1-Nov-11 8:34am    
Good..........arya1685
add some more description to your question... what type of table you want to view, html or database table ?
 
Share this answer
 
myGridView.DataSource = someDataTable;

You can also bind a DataGridView to lists, BindingList<T>s and DataViews.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900