Click here to Skip to main content
15,887,399 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How do I load the datagrid with values when the page_load event occurs?(from database:sql server 2005)

I'm using asp.net,C#,visual studio 2005

Any help?

regards
karan
Posted
Updated 8-May-11 21:27pm
v2
Comments
Dalek Dave 9-May-11 3:27am    
Edited for Grammar.

 
Share this answer
 
Comments
Dalek Dave 9-May-11 3:28am    
Nice link.
try this

C#
if (!IsPostBack)
            {
                BindGrid();
            }
public void BindGrid()
        {
            Con = new SqlConnection("Your Connection Details");
            Con.Open();
            dt = new SqlDataAdapter("Select * from table", Con);
            DataSet ds = new DataSet();
            dt.Fill(ds);
            GridView1.DataSource = ds;
            GridView1.DataBind();
            Con.Close();
        }
 
Share this answer
 
Comments
karan joshua 9-May-11 3:14am    
thank u....

wht is the event GridView1_RowDataBound();

when it occcurs?

whether when :the data is bound to the gridview from the database?
Dalek Dave 9-May-11 3:27am    
Good answer.
You need to learn about events

Grid Vew Events
 
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