View Single Post
  #6 (permalink)  
Old May 25th, 2007, 07:07 AM
pavank pavank is offline
Registered User
 
Join Date: May 2007
Location: guntur, ap, India.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to pavank
Default

Take one function like

private void fillgrid()
{
     here take sqlconnection

   and using sqldataadapter or sqlcommand select query for filling in girdview

 like
    sqldataadapter sqlda=new sqldataadapter(sqlquery,con);
 or
     sqlcommand sqlcmd=new sqlcommand(sqlquery,con);

   for sqldataadapter take dataset

  as dataset ds=new dataset();

    and fill sqldataadapter with dataset for getting data like

 da.fill(ds);

 and write

 gridview1.datasource=ds; // gridview1 is id of gridview.
 gridview1.databind();

}

you call this function in page_load...

like

 if(!ispostback)
   fillgrid();

use this one .....

gud luck
bye










}

pavan