ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2019 www.aspforums.com. All rights reserved.Display Updated values in another View of ASP.Net MultiView control using C# and VB.Net<p>Hi <a class="username" rel="Thuyai"> Thuyai</a>,</p> <p>Check this example. Now please take its reference and correct your code.</p> <p>Here i have used dynamic datatable to populate the record. You need to replace the&nbsp;datatable binding code from database.</p> <p><strong><span style="text-decoration: underline;">HTML</span></strong></p> <pre class="brush: html">&lt;asp:ScriptManager runat=&#34;server&#34; ID=&#39;sm1&#39; EnablePartialRendering=&#34;false&#34;&gt; &lt;/asp:ScriptManager&gt; &lt;asp:UpdatePanel runat=&#34;server&#34; ID=&#39;up1&#39;&gt; &lt;ContentTemplate&gt; &lt;asp:MultiView ID=&#34;mvPeview&#34; runat=&#34;server&#34; ActiveViewIndex=&#34;0&#34; EnableTheming=&#34;True&#34;&gt; &lt;asp:View ID=&#34;vwSubmit&#34; runat=&#34;server&#34;&gt; Select Customer Name &lt;asp:DropDownList ID=&#34;lstFullName&#34; runat=&#34;server&#34; AutoPostBack=&#34;true&#34; OnSelectedIndexChanged=&#34;DropDownList1_SelectedIndexChanged&#34;&gt; &lt;/asp:DropDownList&gt; &lt;br /&gt; Name: &lt;asp:TextBox ID=&#34;txtName&#34; runat=&#34;server&#34; ReadOnly=&#34;true&#34;&gt;&lt;/asp:TextBox&gt; &lt;br /&gt; Department: &lt;asp:TextBox ID=&#34;txtDepartment&#34; runat=&#34;server&#34; OnTextChanged=&#34;UpdateCustomerList&#34; AutoPostBack=&#34;true&#34;&gt;&lt;/asp:TextBox&gt; &lt;br /&gt; Phone: &lt;asp:TextBox ID=&#34;txtPhone&#34; runat=&#34;server&#34; OnTextChanged=&#34;UpdateCustomerList&#34; AutoPostBack=&#34;true&#34;&gt;&lt;/asp:TextBox&gt; &lt;br /&gt; Email: &lt;asp:TextBox ID=&#34;txtEmail&#34; runat=&#34;server&#34; OnTextChanged=&#34;UpdateCustomerList&#34; AutoPostBack=&#34;true&#34;&gt;&lt;/asp:TextBox&gt; &lt;br /&gt; Order: &lt;asp:TextBox ID=&#34;txtOrder&#34; runat=&#34;server&#34; OnTextChanged=&#34;UpdateCustomerList&#34; AutoPostBack=&#34;true&#34;&gt;&lt;/asp:TextBox&gt; Count: &lt;asp:TextBox ID=&#34;txtCount&#34; runat=&#34;server&#34; OnTextChanged=&#34;UpdateCustomerList&#34; AutoPostBack=&#34;true&#34;&gt;&lt;/asp:TextBox&gt; &lt;br /&gt; &lt;hr /&gt; Name: &lt;asp:Label ID=&#34;lblName&#34; runat=&#34;server&#34;&gt;&lt;/asp:Label&gt; &lt;br /&gt; &lt;asp:Label ID=&#34;lblDepartment&#34; runat=&#34;server&#34;&gt;&lt;/asp:Label&gt; &lt;br /&gt; &lt;asp:Label ID=&#34;lblEmail&#34; runat=&#34;server&#34;&gt;&lt;/asp:Label&gt; &lt;br /&gt; &lt;asp:Label ID=&#34;lblPhone&#34; runat=&#34;server&#34;&gt;&lt;/asp:Label&gt;&lt;/span&gt; &lt;br /&gt; &lt;asp:Label ID=&#34;lblOrder&#34; runat=&#34;server&#34;&gt;&lt;/asp:Label&gt; and &lt;asp:Label ID=&#34;lblCount&#34; runat=&#34;server&#34;&gt;&lt;/asp:Label&gt; &lt;br /&gt; &lt;/asp:View&gt; &lt;asp:View ID=&#34;vwResult&#34; runat=&#34;server&#34;&gt; &lt;/asp:View&gt; &lt;/asp:MultiView&gt; &lt;/ContentTemplate&gt; &lt;/asp:UpdatePanel&gt;</pre> <p><span style="text-decoration: underline;"><strong>Namespaces</strong></span></p> <p><strong>C#</strong></p> <pre class="brush: csharp">using System.Data; </pre> <p><strong>VB.Bet</strong></p> <pre class="brush: vb">Imports System.Data</pre> <p><strong><span style="text-decoration: underline;">Code</span></strong></p> <p><strong>C#</strong></p> <pre class="brush: csharp">protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { lstFullName.Items.Add(new ListItem(&#34;Select CustDisplayname&#34;, &#34;&#34;)); lstFullName.AppendDataBoundItems = true; DataTable dt = GetCustomerContactList(); lstFullName.DataSource = dt; lstFullName.DataTextField = &#34;CustDisplayname&#34;; lstFullName.DataValueField = &#34;CustDisplayname&#34;; lstFullName.DataBind(); } } protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { DataTable dt = GetCustomerContactList().Select(&#34;CustDisplayname=&#39;&#34; + lstFullName.SelectedItem.Value + &#34;&#39;&#34;).CopyToDataTable(); txtName.Text = dt.Rows[0][&#34;CustDisplayname&#34;].ToString(); txtDepartment.Text = dt.Rows[0][&#34;dept_list&#34;].ToString(); txtEmail.Text = dt.Rows[0][&#34;email&#34;].ToString(); txtPhone.Text = dt.Rows[0][&#34;telNumber&#34;].ToString(); txtOrder.Text = dt.Rows[0][&#34;numberOrder&#34;].ToString(); txtCount.Text = dt.Rows[0][&#34;Count&#34;].ToString(); lblName.Text = dt.Rows[0][&#34;CustDisplayname&#34;].ToString(); lblDepartment.Text = dt.Rows[0][&#34;dept_list&#34;].ToString(); lblEmail.Text = dt.Rows[0][&#34;email&#34;].ToString(); lblPhone.Text = dt.Rows[0][&#34;telNumber&#34;].ToString(); lblOrder.Text = dt.Rows[0][&#34;numberOrder&#34;].ToString(); lblCount.Text = dt.Rows[0][&#34;Count&#34;].ToString(); } protected void UpdateCustomerList(object sender, EventArgs e) { string department = txtDepartment.Text.Trim(); string email = txtEmail.Text.Trim(); string phone = txtPhone.Text.Trim(); string order = txtOrder.Text.Trim(); string count = txtCount.Text.Trim(); DataTable dtCustomer = Session[&#34;CustomerList&#34;] as DataTable; foreach (DataRow dr in dtCustomer.Rows) { if (dr[&#34;CustDisplayname&#34;].ToString() == lstFullName.SelectedItem.Value) { dr[&#34;dept_list&#34;] = department; dr[&#34;email&#34;] = email; dr[&#34;telNumber&#34;] = phone; dr[&#34;numberOrder&#34;] = order; dr[&#34;Count&#34;] = count; } } Session[&#34;CustomerList&#34;] = dtCustomer; DataTable dt = (Session[&#34;CustomerList&#34;] as DataTable).Select(&#34;CustDisplayname=&#39;&#34; + lstFullName.SelectedItem.Value + &#34;&#39;&#34;).CopyToDataTable(); lblName.Text = dt.Rows[0][&#34;CustDisplayname&#34;].ToString(); lblDepartment.Text = dt.Rows[0][&#34;dept_list&#34;].ToString(); lblEmail.Text = dt.Rows[0][&#34;email&#34;].ToString(); lblPhone.Text = dt.Rows[0][&#34;telNumber&#34;].ToString(); lblOrder.Text = dt.Rows[0][&#34;numberOrder&#34;].ToString(); lblCount.Text = dt.Rows[0][&#34;Count&#34;].ToString(); } private DataTable GetCustomerContactList() { DataTable dt; if (Session[&#34;CustomerList&#34;] == null) { dt = new DataTable(); dt.Columns.AddRange(new DataColumn[] { new DataColumn(&#34;CustDisplayname&#34;, typeof(string)), new DataColumn(&#34;dept_list&#34;, typeof(string)), new DataColumn(&#34;email&#34;, typeof(string)), new DataColumn(&#34;telNumber&#34;, typeof(Int64)), new DataColumn(&#34;numberOrder&#34;, typeof(int)), new DataColumn(&#34;Count&#34;, typeof(int)) }); dt.Rows.Add(&#34;John Hammond&#34;, &#34;Computer&#34;, &#34;test@test.com&#34;, 1111, 1001, 8); dt.Rows.Add(&#34;Mudassar Khan&#34;, &#34;IT&#34;, &#34;test@test.com&#34;, 2222, 1002, 5); dt.Rows.Add(&#34;Suzanne Mathews&#34;, &#34;IT&#34;, &#34;test@test.com&#34;, 3333, 1003, 10); dt.Rows.Add(&#34;Robert Schidner&#34;, &#34;Computer&#34;, &#34;test@test.com&#34;, 4444, 1004, 2); Session[&#34;CustomerList&#34;] = dt; } else { dt = Session[&#34;CustomerList&#34;] as DataTable; } return dt; }</pre> <p><strong>VB.Net</strong></p> <pre class="brush: vb">Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load If Not IsPostBack Then lstFullName.Items.Add(New ListItem(&#34;Select CustDisplayname&#34;, &#34;&#34;)) lstFullName.AppendDataBoundItems = True Dim dt As DataTable = GetCustomerContactList() lstFullName.DataSource = dt lstFullName.DataTextField = &#34;CustDisplayname&#34; lstFullName.DataValueField = &#34;CustDisplayname&#34; lstFullName.DataBind() End If End Sub Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Dim dt As DataTable = GetCustomerContactList().Select(&#34;CustDisplayname=&#39;&#34; &amp; lstFullName.SelectedItem.Value &amp; &#34;&#39;&#34;).CopyToDataTable() txtName.Text = dt.Rows(0)(&#34;CustDisplayname&#34;).ToString() txtDepartment.Text = dt.Rows(0)(&#34;dept_list&#34;).ToString() txtEmail.Text = dt.Rows(0)(&#34;email&#34;).ToString() txtPhone.Text = dt.Rows(0)(&#34;telNumber&#34;).ToString() txtOrder.Text = dt.Rows(0)(&#34;numberOrder&#34;).ToString() txtCount.Text = dt.Rows(0)(&#34;Count&#34;).ToString() lblName.Text = dt.Rows(0)(&#34;CustDisplayname&#34;).ToString() lblDepartment.Text = dt.Rows(0)(&#34;dept_list&#34;).ToString() lblEmail.Text = dt.Rows(0)(&#34;email&#34;).ToString() lblPhone.Text = dt.Rows(0)(&#34;telNumber&#34;).ToString() lblOrder.Text = dt.Rows(0)(&#34;numberOrder&#34;).ToString() lblCount.Text = dt.Rows(0)(&#34;Count&#34;).ToString() End Sub Protected Sub UpdateCustomerList(ByVal sender As Object, ByVal e As EventArgs) Dim department As String = txtDepartment.Text.Trim() Dim email As String = txtEmail.Text.Trim() Dim phone As String = txtPhone.Text.Trim() Dim order As String = txtOrder.Text.Trim() Dim count As String = txtCount.Text.Trim() Dim dtCustomer As DataTable = TryCast(Session(&#34;CustomerList&#34;), DataTable) For Each dr As DataRow In dtCustomer.Rows If dr(&#34;CustDisplayname&#34;).ToString() = lstFullName.SelectedItem.Value Then dr(&#34;dept_list&#34;) = department dr(&#34;email&#34;) = email dr(&#34;telNumber&#34;) = phone dr(&#34;numberOrder&#34;) = order dr(&#34;Count&#34;) = count End If Next Session(&#34;CustomerList&#34;) = dtCustomer Dim dt As DataTable = (TryCast(Session(&#34;CustomerList&#34;), DataTable)) _ .Select(&#34;CustDisplayname=&#39;&#34; &amp; lstFullName.SelectedItem.Value &amp; &#34;&#39;&#34;).CopyToDataTable() lblName.Text = dt.Rows(0)(&#34;CustDisplayname&#34;).ToString() lblDepartment.Text = dt.Rows(0)(&#34;dept_list&#34;).ToString() lblEmail.Text = dt.Rows(0)(&#34;email&#34;).ToString() lblPhone.Text = dt.Rows(0)(&#34;telNumber&#34;).ToString() lblOrder.Text = dt.Rows(0)(&#34;numberOrder&#34;).ToString() lblCount.Text = dt.Rows(0)(&#34;Count&#34;).ToString() End Sub Private Function GetCustomerContactList() As DataTable Dim dt As DataTable If Session(&#34;CustomerList&#34;) Is Nothing Then dt = New DataTable() dt.Columns.AddRange(New DataColumn() {New DataColumn(&#34;CustDisplayname&#34;, GetType(String)), New DataColumn(&#34;dept_list&#34;, GetType(String)), New DataColumn(&#34;email&#34;, GetType(String)), New DataColumn(&#34;telNumber&#34;, GetType(Int64)), New DataColumn(&#34;numberOrder&#34;, GetType(Integer)), New DataColumn(&#34;Count&#34;, GetType(Integer))}) dt.Rows.Add(&#34;John Hammond&#34;, &#34;Computer&#34;, &#34;test@test.com&#34;, 1111, 1001, 8) dt.Rows.Add(&#34;Mudassar Khan&#34;, &#34;IT&#34;, &#34;test@test.com&#34;, 2222, 1002, 5) dt.Rows.Add(&#34;Suzanne Mathews&#34;, &#34;IT&#34;, &#34;test@test.com&#34;, 3333, 1003, 10) dt.Rows.Add(&#34;Robert Schidner&#34;, &#34;Computer&#34;, &#34;test@test.com&#34;, 4444, 1004, 2) Session(&#34;CustomerList&#34;) = dt Else dt = TryCast(Session(&#34;CustomerList&#34;), DataTable) End If Return dt End Function</pre> <p><strong><span style="text-decoration: underline;">Screenshot</span></strong></p> <p><img src="https://i.imgur.com/EuNt4pE.gif" alt="" /></p>https://www.aspforums.net:443/Threads/106571/Display-Updated-values-in-another-View-of-ASPNet-MultiView-control-using-C-and-VBNet/https://www.aspforums.net:443/Threads/106571/Display-Updated-values-in-another-View-of-ASPNet-MultiView-control-using-C-and-VBNet/Mon, 26 Aug 2019 07:22:02 GMT