{"id":127901,"date":"2023-05-04T12:43:06","date_gmt":"2023-05-04T07:13:06","guid":{"rendered":"https:\/\/www.vskills.in\/certification\/tutorial\/?page_id=127901"},"modified":"2024-04-12T14:15:22","modified_gmt":"2024-04-12T08:45:22","slug":"introducing-the-formview-control-2","status":"publish","type":"page","link":"https:\/\/www.vskills.in\/certification\/tutorial\/introducing-the-formview-control-2\/","title":{"rendered":"Introducing the FormView Control"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\"><strong>Introducing the FormView Control<\/strong><\/h4>\n\n\n\n<p>The FormView control in ASP.NET is used to display a single record at a time from a data source. It is similar to the DetailsView control, but offers more flexibility in terms of customizing the layout and appearance of the displayed data.<\/p>\n\n\n\n<p>To use the FormView control, you need to perform the following steps:<\/p>\n\n\n\n<p>Define the FormView control in your ASPX page. This can be done by adding the following code:<\/p>\n\n\n\n<p>&lt;asp:FormView ID=&#8221;FormView1&#8243; runat=&#8221;server&#8221;&gt;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; &lt;!&#8211; Define the layout of the control here &#8211;&gt;<\/p>\n\n\n\n<p>&lt;\/asp:FormView&gt;<\/p>\n\n\n\n<p>Set the data source of the FormView control. This can be done by setting the DataSource property of the control to an instance of a data source control. For example, you can use the SqlDataSource control to retrieve data from a SQL Server database:<\/p>\n\n\n\n<p>&lt;asp:FormView ID=&#8221;FormView1&#8243; runat=&#8221;server&#8221; DataSourceID=&#8221;SqlDataSource1&#8243;&gt;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; &lt;!&#8211; Define the layout of the control here &#8211;&gt;<\/p>\n\n\n\n<p>&lt;\/asp:FormView&gt;<\/p>\n\n\n\n<p>&lt;asp:SqlDataSource ID=&#8221;SqlDataSource1&#8243; runat=&#8221;server&#8221; ConnectionString=&#8221;&#8230;&#8221;&gt;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; &lt;!&#8211; Define the SQL query or stored procedure to retrieve data here &#8211;&gt;<\/p>\n\n\n\n<p>&lt;\/asp:SqlDataSource&gt;<\/p>\n\n\n\n<p>Define the layout of the FormView control. This can be done using templates for different modes of the control (such as Edit, Insert, Item, and Empty modes). For example, to display the data in the Item mode, you can use the following code:<\/p>\n\n\n\n<p>&lt;asp:FormView ID=&#8221;FormView1&#8243; runat=&#8221;server&#8221; DataSourceID=&#8221;SqlDataSource1&#8243;&gt;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; &lt;ItemTemplate&gt;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;div&gt;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;span&gt;First Name:&lt;\/span&gt;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;asp:Label ID=&#8221;FirstNameLabel&#8221; runat=&#8221;server&#8221; Text='&lt;%# Eval(&#8220;FirstName&#8221;) %&gt;&#8217; \/&gt;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;\/div&gt;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;div&gt;<\/p>\n\n\n\n<p>&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;span&gt;Last Name:&lt;\/span&gt;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;asp:Label ID=&#8221;LastNameLabel&#8221; runat=&#8221;server&#8221; Text='&lt;%# Eval(&#8220;LastName&#8221;) %&gt;&#8217; \/&gt;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;\/div&gt;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;!&#8211; Add more fields here as needed &#8211;&gt;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; &lt;\/ItemTemplate&gt;<\/p>\n\n\n\n<p>&lt;\/asp:FormView&gt;<\/p>\n\n\n\n<p>This code defines an ItemTemplate that displays the &#8220;First Name&#8221; and &#8220;Last Name&#8221; fields of the data source using Label controls. The Eval method is used to bind the value of the data field to the Text property of the Label control.<\/p>\n\n\n\n<p>Optionally, you can add support for editing, inserting, and deleting data by defining templates for the Edit, Insert, and Empty modes. For example, to add support for editing the data, you can use the following code:<\/p>\n\n\n\n<p>&lt;asp:FormView ID=&#8221;FormView1&#8243; runat=&#8221;server&#8221; DataSourceID=&#8221;SqlDataSource1&#8243;&gt;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; &lt;ItemTemplate&gt;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;!&#8211; Define the layout for displaying the data in the Item mode &#8211;&gt;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; &lt;\/ItemTemplate&gt;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; &lt;EditItemTemplate&gt;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;div&gt;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;span&gt;First Name:&lt;\/span&gt;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;asp:TextBox ID=&#8221;FirstNameTextBox&#8221; runat=&#8221;server&#8221; Text='&lt;%# Bind(&#8220;FirstName&#8221;) %&gt;&#8217; \/&gt;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;\/div&gt;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;div&gt;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;span&gt;Last Name:&lt;\/span&gt;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;asp:TextBox ID=&#8221;LastNameTextBox&#8221; runat=&#8221;server&#8221; Text='&lt;%# Bind(&#8220;LastName&#8221;) %&gt;&#8217; \/&gt;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;\/div&gt;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;!&#8211; Add more fields here as needed &#8211;&gt;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; &lt;\/EditItemTemplate&gt;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; &lt;InsertItemTemplate&gt;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;!&#8211; Define the layout for inserting new data here &#8211;&gt;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp; &lt;\/InsertItemTemplate&gt;<\/p>\n\n\n\n<p>\u00a0\u00a0\u00a0 &lt;<\/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>Introducing the FormView Control The FormView control in ASP.NET is used to display a single record at a time from a data source. It is similar to the DetailsView control, but offers more flexibility in terms of customizing the layout and appearance of the displayed data. To use the FormView control, you need to perform&#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-127901","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>Introducing the FormView Control - Tutorial<\/title>\n<meta name=\"description\" content=\"Introducing the FormView Control\" \/>\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\/introducing-the-formview-control-2\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Introducing the FormView Control - Tutorial\" \/>\n<meta property=\"og:description\" content=\"Introducing the FormView Control\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.vskills.in\/certification\/tutorial\/introducing-the-formview-control-2\/\" \/>\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:22+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\/introducing-the-formview-control-2\/\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/introducing-the-formview-control-2\/\",\"name\":\"Introducing the FormView Control - Tutorial\",\"isPartOf\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#website\"},\"datePublished\":\"2023-05-04T07:13:06+00:00\",\"dateModified\":\"2024-04-12T08:45:22+00:00\",\"description\":\"Introducing the FormView Control\",\"breadcrumb\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/introducing-the-formview-control-2\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.vskills.in\/certification\/tutorial\/introducing-the-formview-control-2\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/introducing-the-formview-control-2\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.vskills.in\/certification\/tutorial\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Introducing the FormView Control\"}]},{\"@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":"Introducing the FormView Control - Tutorial","description":"Introducing the FormView Control","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\/introducing-the-formview-control-2\/","og_locale":"en_US","og_type":"article","og_title":"Introducing the FormView Control - Tutorial","og_description":"Introducing the FormView Control","og_url":"https:\/\/www.vskills.in\/certification\/tutorial\/introducing-the-formview-control-2\/","og_site_name":"Tutorial","article_publisher":"https:\/\/www.facebook.com\/vskills.in\/","article_modified_time":"2024-04-12T08:45:22+00:00","twitter_misc":{"Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/introducing-the-formview-control-2\/","url":"https:\/\/www.vskills.in\/certification\/tutorial\/introducing-the-formview-control-2\/","name":"Introducing the FormView Control - Tutorial","isPartOf":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#website"},"datePublished":"2023-05-04T07:13:06+00:00","dateModified":"2024-04-12T08:45:22+00:00","description":"Introducing the FormView Control","breadcrumb":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/introducing-the-formview-control-2\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.vskills.in\/certification\/tutorial\/introducing-the-formview-control-2\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/introducing-the-formview-control-2\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.vskills.in\/certification\/tutorial\/"},{"@type":"ListItem","position":2,"name":"Introducing the FormView Control"}]},{"@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\/127901","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=127901"}],"version-history":[{"count":2,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages\/127901\/revisions"}],"predecessor-version":[{"id":127907,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages\/127901\/revisions\/127907"}],"wp:attachment":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/media?parent=127901"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/categories?post=127901"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/tags?post=127901"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}