{"id":128390,"date":"2023-05-04T17:08:47","date_gmt":"2023-05-04T11:38:47","guid":{"rendered":"https:\/\/www.vskills.in\/certification\/tutorial\/?page_id=128390"},"modified":"2024-04-12T14:15:26","modified_gmt":"2024-04-12T08:45:26","slug":"fetching-data-for-the-master","status":"publish","type":"page","link":"https:\/\/www.vskills.in\/certification\/tutorial\/fetching-data-for-the-master\/","title":{"rendered":"Fetching Data for the Master"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\"><strong>Fetching Data for the Master<\/strong><\/h4>\n\n\n\n<p>To fetch data for the master page in ASP.NET, you can use a data source control such as the SqlDataSource or ObjectDataSource. Here&#8217;s an example of using the SqlDataSource to fetch data for the master page:<\/p>\n\n\n\n<p>Add a SqlDataSource control to your master page:<\/p>\n\n\n\n<p>&lt;asp:SqlDataSource ID=&#8221;SqlDataSource1&#8243; runat=&#8221;server&#8221; ConnectionString=&#8221;&lt;%$ ConnectionStrings:NorthwindConnectionString %&gt;&#8221; SelectCommand=&#8221;SELECT CategoryID, CategoryName FROM Categories&#8221;&gt;&lt;\/asp:SqlDataSource&gt;<\/p>\n\n\n\n<p>This code defines a SqlDataSource control with an ID of &#8220;SqlDataSource1&#8221; that retrieves data from the &#8220;Categories&#8221; table of the Northwind database.<\/p>\n\n\n\n<p>Bind the data to a control on the master page:<\/p>\n\n\n\n<p>&lt;asp:Menu ID=&#8221;Menu1&#8243; runat=&#8221;server&#8221; DataSourceID=&#8221;SqlDataSource1&#8243; DataTextField=&#8221;CategoryName&#8221; DataValueField=&#8221;CategoryID&#8221;&gt;&lt;\/asp:Menu&gt;<\/p>\n\n\n\n<p>This code binds the data from the SqlDataSource control to a Menu control with an ID of &#8220;Menu1&#8221;. The DataTextField property specifies the field in the data source to display as the text for each menu item, and the DataValueField property specifies the field in the data source to use as the value for each menu item. When the master page is loaded, the SqlDataSource control retrieves the data from the database and populates the Menu control with the categories. Users can then click on a category to view the detail pages associated with that category.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Apply for ASP.NET Certification Now!!<\/h3>\n\n\n\n<p><a href=\"https:\/\/www.vskills.in\/certification\/certified-aspnet-programmer\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/www.vskills.in\/certification\/certified-aspnet-programmer<\/a><\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong><a href=\"https:\/\/www.vskills.in\/certification\/tutorial\/asp-net\/\" target=\"_blank\" rel=\"noreferrer noopener\">Back to Tutorial<\/a><\/strong><\/h4>\n","protected":false},"excerpt":{"rendered":"<p>Fetching Data for the Master To fetch data for the master page in ASP.NET, you can use a data source control such as the SqlDataSource or ObjectDataSource. Here&#8217;s an example of using the SqlDataSource to fetch data for the master page: Add a SqlDataSource control to your master page: &lt;asp:SqlDataSource ID=&#8221;SqlDataSource1&#8243; runat=&#8221;server&#8221; ConnectionString=&#8221;&lt;%$ ConnectionStrings:NorthwindConnectionString %&gt;&#8221;&#8230;<\/p>\n","protected":false},"author":22,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"categories":[3339],"tags":[],"class_list":["post-128390","page","type-page","status-publish","hentry","category-asp-net-2"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Fetching Data for the Master - Tutorial<\/title>\n<meta name=\"description\" content=\"Fetching Data for the Master\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.vskills.in\/certification\/tutorial\/fetching-data-for-the-master\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Fetching Data for the Master - Tutorial\" \/>\n<meta property=\"og:description\" content=\"Fetching Data for the Master\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.vskills.in\/certification\/tutorial\/fetching-data-for-the-master\/\" \/>\n<meta property=\"og:site_name\" content=\"Tutorial\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/vskills.in\/\" \/>\n<meta property=\"article:modified_time\" content=\"2024-04-12T08:45:26+00:00\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/fetching-data-for-the-master\/\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/fetching-data-for-the-master\/\",\"name\":\"Fetching Data for the Master - Tutorial\",\"isPartOf\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#website\"},\"datePublished\":\"2023-05-04T11:38:47+00:00\",\"dateModified\":\"2024-04-12T08:45:26+00:00\",\"description\":\"Fetching Data for the Master\",\"breadcrumb\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/fetching-data-for-the-master\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.vskills.in\/certification\/tutorial\/fetching-data-for-the-master\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/fetching-data-for-the-master\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.vskills.in\/certification\/tutorial\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Fetching Data for the Master\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#website\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/\",\"name\":\"Tutorial\",\"description\":\"Vskills - A initiative in elearning and certification\",\"publisher\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.vskills.in\/certification\/tutorial\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#organization\",\"name\":\"Vskills\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg\",\"contentUrl\":\"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg\",\"width\":73,\"height\":55,\"caption\":\"Vskills\"},\"image\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/vskills.in\/\",\"https:\/\/x.com\/vskills_in\",\"https:\/\/www.linkedin.com\/company-beta\/1371554\/\",\"https:\/\/www.youtube.com\/channel\/UCMWnscxPwRF_PqXo9B7q_Tw\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Fetching Data for the Master - Tutorial","description":"Fetching Data for the Master","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:\/\/www.vskills.in\/certification\/tutorial\/fetching-data-for-the-master\/","og_locale":"en_US","og_type":"article","og_title":"Fetching Data for the Master - Tutorial","og_description":"Fetching Data for the Master","og_url":"https:\/\/www.vskills.in\/certification\/tutorial\/fetching-data-for-the-master\/","og_site_name":"Tutorial","article_publisher":"https:\/\/www.facebook.com\/vskills.in\/","article_modified_time":"2024-04-12T08:45:26+00:00","twitter_misc":{"Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/fetching-data-for-the-master\/","url":"https:\/\/www.vskills.in\/certification\/tutorial\/fetching-data-for-the-master\/","name":"Fetching Data for the Master - Tutorial","isPartOf":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#website"},"datePublished":"2023-05-04T11:38:47+00:00","dateModified":"2024-04-12T08:45:26+00:00","description":"Fetching Data for the Master","breadcrumb":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/fetching-data-for-the-master\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.vskills.in\/certification\/tutorial\/fetching-data-for-the-master\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/fetching-data-for-the-master\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.vskills.in\/certification\/tutorial\/"},{"@type":"ListItem","position":2,"name":"Fetching Data for the Master"}]},{"@type":"WebSite","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#website","url":"https:\/\/www.vskills.in\/certification\/tutorial\/","name":"Tutorial","description":"Vskills - A initiative in elearning and certification","publisher":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.vskills.in\/certification\/tutorial\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#organization","name":"Vskills","url":"https:\/\/www.vskills.in\/certification\/tutorial\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/","url":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg","contentUrl":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg","width":73,"height":55,"caption":"Vskills"},"image":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/vskills.in\/","https:\/\/x.com\/vskills_in","https:\/\/www.linkedin.com\/company-beta\/1371554\/","https:\/\/www.youtube.com\/channel\/UCMWnscxPwRF_PqXo9B7q_Tw"]}]}},"_links":{"self":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages\/128390","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/users\/22"}],"replies":[{"embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/comments?post=128390"}],"version-history":[{"count":2,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages\/128390\/revisions"}],"predecessor-version":[{"id":128394,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages\/128390\/revisions\/128394"}],"wp:attachment":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/media?parent=128390"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/categories?post=128390"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/tags?post=128390"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}