{"id":128395,"date":"2023-05-04T17:13:24","date_gmt":"2023-05-04T11:43:24","guid":{"rendered":"https:\/\/www.vskills.in\/certification\/tutorial\/?page_id=128395"},"modified":"2024-04-12T14:15:26","modified_gmt":"2024-04-12T08:45:26","slug":"fetching-data-for-the-details","status":"publish","type":"page","link":"https:\/\/www.vskills.in\/certification\/tutorial\/fetching-data-for-the-details\/","title":{"rendered":"Fetching Data for the Details"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\"><strong>Fetching Data for the Details<\/strong><\/h4>\n\n\n\n<p>To fetch data for the details 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 details page:<\/p>\n\n\n\n<p>Add a SqlDataSource control to your details 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 ProductID, ProductName, UnitPrice FROM Products WHERE CategoryID=@CategoryID&#8221;&gt;<\/p>\n\n\n\n<p>&nbsp;&nbsp; &lt;SelectParameters&gt;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;asp:QueryStringParameter Name=&#8221;CategoryID&#8221; QueryStringField=&#8221;CategoryID&#8221; Type=&#8221;Int32&#8243; \/&gt;<\/p>\n\n\n\n<p>&nbsp;&nbsp; &lt;\/SelectParameters&gt;<\/p>\n\n\n\n<p>&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;Products&#8221; table of the Northwind database. The SelectCommand specifies a parameterized SQL query that retrieves products with a specified category ID. The parameter is defined using a QueryStringParameter that gets its value from the &#8220;CategoryID&#8221; query string parameter.<\/p>\n\n\n\n<p>Add a control to display the data:<\/p>\n\n\n\n<p>&lt;asp:DetailsView ID=&#8221;DetailsView1&#8243; runat=&#8221;server&#8221; DataSourceID=&#8221;SqlDataSource1&#8243; AutoGenerateRows=&#8221;False&#8221;&gt;<\/p>\n\n\n\n<p>&nbsp;&nbsp; &lt;Fields&gt;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;asp:BoundField DataField=&#8221;ProductID&#8221; HeaderText=&#8221;Product ID&#8221; \/&gt;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;asp:BoundField DataField=&#8221;ProductName&#8221; HeaderText=&#8221;Product Name&#8221; \/&gt;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;asp:BoundField DataField=&#8221;UnitPrice&#8221; HeaderText=&#8221;Unit Price&#8221; DataFormatString=&#8221;{0:C}&#8221; \/&gt;<\/p>\n\n\n\n<p>&nbsp;&nbsp; &lt;\/Fields&gt;<\/p>\n\n\n\n<p>&lt;\/asp:DetailsView&gt;<\/p>\n\n\n\n<p>This code adds a DetailsView control with an ID of &#8220;DetailsView1&#8221; to the details page. The DataSourceID property is set to &#8220;SqlDataSource1&#8221; to bind the data from the SqlDataSource control to the DetailsView control. The AutoGenerateRows property is set to &#8220;False&#8221; to specify that the details fields are defined manually. The Fields collection specifies the details fields to display, which are bound to the &#8220;ProductID&#8221;, &#8220;ProductName&#8221;, and &#8220;UnitPrice&#8221; fields of the SqlDataSource control. The DataFormatString property of the &#8220;UnitPrice&#8221; field is set to &#8220;{0:C}&#8221; to format the unit price as a currency value. When the details page is loaded, the SqlDataSource control retrieves the data from the database based on the category ID specified in the query string, and populates the DetailsView control with the product details.<\/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 Details To fetch data for the details 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 details page: Add a SqlDataSource control to your details 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-128395","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 Details - Tutorial<\/title>\n<meta name=\"description\" content=\"Fetching Data for the Details\" \/>\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-details\/\" \/>\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 Details - Tutorial\" \/>\n<meta property=\"og:description\" content=\"Fetching Data for the Details\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.vskills.in\/certification\/tutorial\/fetching-data-for-the-details\/\" \/>\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=\"2 minutes\" \/>\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-details\/\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/fetching-data-for-the-details\/\",\"name\":\"Fetching Data for the Details - Tutorial\",\"isPartOf\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#website\"},\"datePublished\":\"2023-05-04T11:43:24+00:00\",\"dateModified\":\"2024-04-12T08:45:26+00:00\",\"description\":\"Fetching Data for the Details\",\"breadcrumb\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/fetching-data-for-the-details\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.vskills.in\/certification\/tutorial\/fetching-data-for-the-details\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/fetching-data-for-the-details\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.vskills.in\/certification\/tutorial\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Fetching Data for the Details\"}]},{\"@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 Details - Tutorial","description":"Fetching Data for the Details","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-details\/","og_locale":"en_US","og_type":"article","og_title":"Fetching Data for the Details - Tutorial","og_description":"Fetching Data for the Details","og_url":"https:\/\/www.vskills.in\/certification\/tutorial\/fetching-data-for-the-details\/","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":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/fetching-data-for-the-details\/","url":"https:\/\/www.vskills.in\/certification\/tutorial\/fetching-data-for-the-details\/","name":"Fetching Data for the Details - Tutorial","isPartOf":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#website"},"datePublished":"2023-05-04T11:43:24+00:00","dateModified":"2024-04-12T08:45:26+00:00","description":"Fetching Data for the Details","breadcrumb":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/fetching-data-for-the-details\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.vskills.in\/certification\/tutorial\/fetching-data-for-the-details\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/fetching-data-for-the-details\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.vskills.in\/certification\/tutorial\/"},{"@type":"ListItem","position":2,"name":"Fetching Data for the Details"}]},{"@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\/128395","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=128395"}],"version-history":[{"count":2,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages\/128395\/revisions"}],"predecessor-version":[{"id":128401,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages\/128395\/revisions\/128401"}],"wp:attachment":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/media?parent=128395"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/categories?post=128395"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/tags?post=128395"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}