{"id":16852,"date":"2015-06-13T15:07:24","date_gmt":"2015-06-13T10:07:24","guid":{"rendered":"https:\/\/www.thenerdmag.com\/?p=16852"},"modified":"2019-12-27T06:49:35","modified_gmt":"2019-12-27T01:49:35","slug":"binding-list-database-asp-net","status":"publish","type":"post","link":"https:\/\/thenerdmag.com\/binding-list-database-asp-net\/","title":{"rendered":"Binding List with Database in ASP.net"},"content":{"rendered":"

Lastly we told you about the Server Controls in ASP.net<\/a> and today we will explain how to fetch data from database. And display the content on the dropdown list in asp.net web form<\/strong>. So for this purpose we have to make a table in the database first. We will move forward step by step.
\nYou can use any database software. But here I\u2019m using MySQL Server 2012. Open the SQL server. Create a new project. Then in object explorer box you will see many folders. Right click on the database option and create new Database.<\/p>\n

\"a\"

After clicking it a small screen will appear. That will ask for the name and row of the new database. Give it a desired name. I have given it a name Employee. This screen might appear like this. After giving it an appropriate name and no. of required rows press ok button.<\/p>\n

\"b\"

Now after that you have to click the newly created Database in the object explorer. Some folders will be shown here. Right Click the table folder. Click create new table. And then enter the values in the columns section. Right click the CityID and make it primary key. It can\u2019t be null so it will automatically get uncheck. Rest of the values can be null so let it be checked. And enter the type of the data that will be entered. ID can only be integer values so it is set as an integer. While other are set as nvarChar(50) according to the requirement. Now save it. I have saved it with emp name. So here our table is ready.<\/p>\n

\"c\"

Now our table is ready we are ready to write a query and execute it. So let\u2019s write our first query. Click on the new query button and write this query and execute it. As a result box will show that have values in it. For that you have to write another query.<\/p>\n

\"d\"

So to insert the values you have to execute this query.<\/p>\n

\"e\"

You are done with the database now lets move to the Visual Studio for web. Create a new project in visual studio. Add web form in it. Then in the designer view add a drop down list to the form. Now here is time to create a database connection. For that click the tool option then click the add database. A box will appear in front of you. In the server name enter the server name. Then select the database which you have created in the database. Here I have given it Employee name.
\n<\/a><\/p>\n

\"f\"

Now click the web config file in the solution explorer. And you will find connection string tag. You have to give it the database path.\u00a0 Lets see it.<\/p>\n

\"asd\"

Now you have to write the code to fetch the data from the database.
\nClick the dropdownlist and press view code. Then in the load method. Write all the code.<\/p>\n

\"x\"

You are done with the data binding. Now debug it. You will get the end result like this.<\/p>\n

\"z\"

Article Written by Waleed Rashid. More info here<\/a>.<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"

Lastly we told you about the Server Controls in ASP.net and today we will explain how to fetch data from database. And display the content on the dropdown list in asp.net web form. So for this purpose we have to make a table in the database first. We will move forward step by step. You can use any database software. But here I\u2019m using MySQL Server 2012. Open the SQL server. Create a new project. Then in object explorer box […]<\/p>\n","protected":false},"author":1,"featured_media":16808,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[922,158],"tags":[1358,1359,12],"yoast_head":"\nBinding List with Database in ASP.net<\/title>\n<meta name=\"description\" content=\"Today we are here to explain how to fetch data from database, bind it to drop down list and display the content in asp.net web form.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/thenerdmag.com\/binding-list-database-asp-net\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Binding List with Database in ASP.net\" \/>\n<meta property=\"og:description\" content=\"Today we are here to explain how to fetch data from database, bind it to drop down list and display the content in asp.net web form.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/thenerdmag.com\/binding-list-database-asp-net\/\" \/>\n<meta property=\"og:site_name\" content=\"TheNerdMag\" \/>\n<meta property=\"article:publisher\" content=\"http:\/\/www.facebook.com\/TheNerdMag\" \/>\n<meta property=\"article:published_time\" content=\"2015-06-13T10:07:24+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-12-27T01:49:35+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/thenerdmag.com\/wp-content\/uploads\/2015\/06\/asp.net_.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"613\" \/>\n\t<meta property=\"og:image:height\" content=\"194\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Uzair Ahmad Ch\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@TheNerdMag\" \/>\n<meta name=\"twitter:site\" content=\"@TheNerdMag\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Uzair Ahmad Ch\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/thenerdmag.com\/binding-list-database-asp-net\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/thenerdmag.com\/binding-list-database-asp-net\/\"},\"author\":{\"name\":\"Uzair Ahmad Ch\",\"@id\":\"https:\/\/thenerdmag.com\/#\/schema\/person\/4024ad8a2e33e2e2058bd55354f39cd4\"},\"headline\":\"Binding List with Database in ASP.net\",\"datePublished\":\"2015-06-13T10:07:24+00:00\",\"dateModified\":\"2019-12-27T01:49:35+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/thenerdmag.com\/binding-list-database-asp-net\/\"},\"wordCount\":520,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\/\/thenerdmag.com\/#organization\"},\"keywords\":[\"ASP\",\"ASP.net\",\"Microsoft\"],\"articleSection\":[\"Education\",\"Tutorials\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/thenerdmag.com\/binding-list-database-asp-net\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/thenerdmag.com\/binding-list-database-asp-net\/\",\"url\":\"https:\/\/thenerdmag.com\/binding-list-database-asp-net\/\",\"name\":\"Binding List with Database in ASP.net\",\"isPartOf\":{\"@id\":\"https:\/\/thenerdmag.com\/#website\"},\"datePublished\":\"2015-06-13T10:07:24+00:00\",\"dateModified\":\"2019-12-27T01:49:35+00:00\",\"description\":\"Today we are here to explain how to fetch data from database, bind it to drop down list and display the content in asp.net web form.\",\"breadcrumb\":{\"@id\":\"https:\/\/thenerdmag.com\/binding-list-database-asp-net\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/thenerdmag.com\/binding-list-database-asp-net\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/thenerdmag.com\/binding-list-database-asp-net\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/thenerdmag.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Binding List with Database in ASP.net\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/thenerdmag.com\/#website\",\"url\":\"https:\/\/thenerdmag.com\/\",\"name\":\"TheNerdMag\",\"description\":\"Internet - Technology - Gadgets\",\"publisher\":{\"@id\":\"https:\/\/thenerdmag.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/thenerdmag.com\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/thenerdmag.com\/#organization\",\"name\":\"TheNerdMag\",\"url\":\"https:\/\/thenerdmag.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/thenerdmag.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.thenerdmag.com\/wp-content\/uploads\/2021\/08\/TNM-Logo-V2-250.png\",\"contentUrl\":\"https:\/\/www.thenerdmag.com\/wp-content\/uploads\/2021\/08\/TNM-Logo-V2-250.png\",\"width\":250,\"height\":250,\"caption\":\"TheNerdMag\"},\"image\":{\"@id\":\"https:\/\/thenerdmag.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"http:\/\/www.facebook.com\/TheNerdMag\",\"https:\/\/twitter.com\/TheNerdMag\",\"https:\/\/www.instagram.com\/TheNerdMag\/\",\"https:\/\/www.youtube.com\/Thenerdmag\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/thenerdmag.com\/#\/schema\/person\/4024ad8a2e33e2e2058bd55354f39cd4\",\"name\":\"Uzair Ahmad Ch\",\"description\":\"Uzair Ahmad Ch is Founder and Editor in Chief of TheNerdMag. Uzair loves technology, internet and gadgets from childhood. That's why he is so into tech talks, internet news and updates. This interest encouraged him to start a blog about Technology. Currently he is doing Bachelors in Computer Science and leads Team TheNerdMag. TheNerdMag was founded by him in 2012. You can reach him via his social profiles or email him at uzairfreak [at] thenerdmag.com\",\"url\":\"https:\/\/thenerdmag.com\/author\/uzairahmadch\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Binding List with Database in ASP.net","description":"Today we are here to explain how to fetch data from database, bind it to drop down list and display the content in asp.net web form.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/thenerdmag.com\/binding-list-database-asp-net\/","og_locale":"en_US","og_type":"article","og_title":"Binding List with Database in ASP.net","og_description":"Today we are here to explain how to fetch data from database, bind it to drop down list and display the content in asp.net web form.","og_url":"https:\/\/thenerdmag.com\/binding-list-database-asp-net\/","og_site_name":"TheNerdMag","article_publisher":"http:\/\/www.facebook.com\/TheNerdMag","article_published_time":"2015-06-13T10:07:24+00:00","article_modified_time":"2019-12-27T01:49:35+00:00","og_image":[{"width":613,"height":194,"url":"https:\/\/thenerdmag.com\/wp-content\/uploads\/2015\/06\/asp.net_.jpg","type":"image\/jpeg"}],"author":"Uzair Ahmad Ch","twitter_card":"summary_large_image","twitter_creator":"@TheNerdMag","twitter_site":"@TheNerdMag","twitter_misc":{"Written by":"Uzair Ahmad Ch","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/thenerdmag.com\/binding-list-database-asp-net\/#article","isPartOf":{"@id":"https:\/\/thenerdmag.com\/binding-list-database-asp-net\/"},"author":{"name":"Uzair Ahmad Ch","@id":"https:\/\/thenerdmag.com\/#\/schema\/person\/4024ad8a2e33e2e2058bd55354f39cd4"},"headline":"Binding List with Database in ASP.net","datePublished":"2015-06-13T10:07:24+00:00","dateModified":"2019-12-27T01:49:35+00:00","mainEntityOfPage":{"@id":"https:\/\/thenerdmag.com\/binding-list-database-asp-net\/"},"wordCount":520,"commentCount":1,"publisher":{"@id":"https:\/\/thenerdmag.com\/#organization"},"keywords":["ASP","ASP.net","Microsoft"],"articleSection":["Education","Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/thenerdmag.com\/binding-list-database-asp-net\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/thenerdmag.com\/binding-list-database-asp-net\/","url":"https:\/\/thenerdmag.com\/binding-list-database-asp-net\/","name":"Binding List with Database in ASP.net","isPartOf":{"@id":"https:\/\/thenerdmag.com\/#website"},"datePublished":"2015-06-13T10:07:24+00:00","dateModified":"2019-12-27T01:49:35+00:00","description":"Today we are here to explain how to fetch data from database, bind it to drop down list and display the content in asp.net web form.","breadcrumb":{"@id":"https:\/\/thenerdmag.com\/binding-list-database-asp-net\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/thenerdmag.com\/binding-list-database-asp-net\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/thenerdmag.com\/binding-list-database-asp-net\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/thenerdmag.com\/"},{"@type":"ListItem","position":2,"name":"Binding List with Database in ASP.net"}]},{"@type":"WebSite","@id":"https:\/\/thenerdmag.com\/#website","url":"https:\/\/thenerdmag.com\/","name":"TheNerdMag","description":"Internet - Technology - Gadgets","publisher":{"@id":"https:\/\/thenerdmag.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/thenerdmag.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/thenerdmag.com\/#organization","name":"TheNerdMag","url":"https:\/\/thenerdmag.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/thenerdmag.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.thenerdmag.com\/wp-content\/uploads\/2021\/08\/TNM-Logo-V2-250.png","contentUrl":"https:\/\/www.thenerdmag.com\/wp-content\/uploads\/2021\/08\/TNM-Logo-V2-250.png","width":250,"height":250,"caption":"TheNerdMag"},"image":{"@id":"https:\/\/thenerdmag.com\/#\/schema\/logo\/image\/"},"sameAs":["http:\/\/www.facebook.com\/TheNerdMag","https:\/\/twitter.com\/TheNerdMag","https:\/\/www.instagram.com\/TheNerdMag\/","https:\/\/www.youtube.com\/Thenerdmag"]},{"@type":"Person","@id":"https:\/\/thenerdmag.com\/#\/schema\/person\/4024ad8a2e33e2e2058bd55354f39cd4","name":"Uzair Ahmad Ch","description":"Uzair Ahmad Ch is Founder and Editor in Chief of TheNerdMag. Uzair loves technology, internet and gadgets from childhood. That's why he is so into tech talks, internet news and updates. This interest encouraged him to start a blog about Technology. Currently he is doing Bachelors in Computer Science and leads Team TheNerdMag. TheNerdMag was founded by him in 2012. You can reach him via his social profiles or email him at uzairfreak [at] thenerdmag.com","url":"https:\/\/thenerdmag.com\/author\/uzairahmadch\/"}]}},"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"https:\/\/thenerdmag.com\/wp-content\/uploads\/2015\/06\/asp.net_.jpg","jetpack_shortlink":"https:\/\/wp.me\/p2IqIJ-4nO","amp_enabled":true,"_links":{"self":[{"href":"https:\/\/thenerdmag.com\/wp-json\/wp\/v2\/posts\/16852"}],"collection":[{"href":"https:\/\/thenerdmag.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/thenerdmag.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/thenerdmag.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/thenerdmag.com\/wp-json\/wp\/v2\/comments?post=16852"}],"version-history":[{"count":0,"href":"https:\/\/thenerdmag.com\/wp-json\/wp\/v2\/posts\/16852\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/thenerdmag.com\/wp-json\/wp\/v2\/media\/16808"}],"wp:attachment":[{"href":"https:\/\/thenerdmag.com\/wp-json\/wp\/v2\/media?parent=16852"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/thenerdmag.com\/wp-json\/wp\/v2\/categories?post=16852"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/thenerdmag.com\/wp-json\/wp\/v2\/tags?post=16852"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}