dotnetspider.com
Login Login    Register      

TutorialsForumCareer DevelopmentResourcesReviewsJobsInterviewCommunitiesProjectsTraining

Subscribe to Subscribers
Talk to Webmaster
Tony John

Facebook
Google+
Twitter
LinkedIn
Online MembersPhagu Mahato
Nwe Nwe
More...
Join our online Google+ community for Bloggers, Content Writers and Webmasters




Resources » Code Snippets » ASP.NET GridView

Code to bind gridview with DataAdapter


Posted Date:     Category: ASP.NET GridView    
Author: Member Level: Gold    Points: 3


Code to bind gridview with DataAdapter using Asp.Net



 


Note:
->The ConnectionString index value will get from web.config file.


protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
bindRecord();
}

}
Public void bindRecord()
{
SqlConnection con =new SqlConnection(ConfigurationManager.
ConnectionStrings["ConnectionString"].ConnectionString.ToString();)
SqlCommand cmd=new SqlCommand();
cmd.connection=con;
con.open();
cmd.commandText="SELECT * FROM tablename";
SqlDataAdapter da=new SqlDataAdapter(cmd);
Dataset ds=new Dataset();
da.fill(ds);
cmd.ExecuteNonQuery();
grdview.DataSource=ds;
grdview.DataBind();
con.close();


}

Related Resources:


Read related articles: Gridview databind    Gridview data source    Gridview    


Did you like this resource? Share it with your friends and show your love!


Responses to "Code to bind gridview with DataAdapter"

No responses found. Be the first to respond...

Feedbacks      

Post Comment:




  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:   Sign In to fill automatically.
    Email: (Will not be published, but required to validate comment)



    Type the numbers and letters shown on the left.


    Next Resource: How to hide a column of Gridview using asp.net
    Previous Resource: How to display the total of a Particular Column in the footer of the GridView control.
    Return to Resources
    Post New Resource
    Category: ASP.NET GridView


    Post resources and earn money!
     
    More Resources
    Popular Tags   Tag posting guidelines   Search Tags  
    Code to bind gridview with DataAdapter  .  



    Follow us on Twitter: https://twitter.com/dotnetspider

    Active Members
    TodayLast 7 Daysmore...

    Awards & Gifts
    Email subscription
  • .NET Jobs
  • .NET Articles
  • .NET Forums
  • Articles Rss Feeds
    Forum Rss Feeds


    About Us    Contact Us    Copyright    Privacy Policy    Terms Of Use    Revenue Sharing sites   Advertise   Talk to Tony John
    Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India
    2005 - 2012 All Rights Reserved.
    .NET and other trademarks mentioned in this site belong to Microsoft and other respective trademark owners.
    Articles, tutorials and all other content offered here is for educational purpose only.
    We are not associated with Microsoft or its partners.