Click here to Skip to main content
15,936,197 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C#
protected void Page_Load(object sender, EventArgs e)
        {
            //---------------------------Fill Employee-----------------
            if (IsPostBack)
            {
                SqlDataAdapter da = new SqlDataAdapter("select empno,Namee from employee",con);
                DataSet ds = new DataSet();
                da.Fill(ds);
                GridView1.DataSource = ds;
                GridView1.DataBind();
            }            
            //-----------------------------End---------------------------
        }
[Edit]Code block added[/Edit]
Posted
Updated 8-Mar-13 5:04am
v2
Comments
giri001 8-Mar-13 9:56am    
select empno,Namee from employee.....check your query plz.
Gilbertinino 8-Mar-13 9:58am    
my query is running correct in database and its retuning some data
Pallavi Waikar 8-Mar-13 10:17am    
first time it not going to work because u r checking for if (IsPostBack)..on second time on page postback will show values..if not then there is might be any problem

1 solution

C#
protected void Page_Load(object sender, EventArgs e)
{
//---------------------------Fill Employee-----------------
if (IsPostBack==false)
{
SqlDataAdapter da = new SqlDataAdapter("select empno,Namee from employee",con);
DataSet ds = new DataSet();
da.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
}
[Edit]Code block added[/Edit]
 
Share this answer
 
v2

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


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