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.Set TextBox value when TextMode is Password on ASP.Net GridView RowCommand using C# and VB.Net<p>Hi <a class="username" rel="Saiansh"> Saiansh</a>,</p> <p>You will not get the password with $. As you are spliting the CommandArgument string with $. So while assigning multiple value to CommandArgument through Evel use other character to concadinate the string. But there will be same issue happen when you are spliting with the character. So the better way is use HiddenField and save the password in HiddenFeld and retrieve from HiddenField.</p> <p><span style="text-decoration: underline;"><strong>HTML</strong></span></p> <pre class="brush: html">&lt;asp:GridView runat=&#34;server&#34; ID=&#34;gdvUsers&#34; OnRowCommand=&#34;gdvUsers_RowCommand&#34;&gt; &lt;Columns&gt; &lt;asp:TemplateField&gt; &lt;ItemTemplate&gt; &lt;asp:HiddenField ID=&#34;hfPassword&#34; runat=&#34;server&#34; Value=&#39;&lt;%#Eval(&#34;password&#34;) %&gt;&#39; /&gt; &lt;asp:LinkButton ID=&#34;lnkEdit&#34; runat=&#34;server&#34; Text=&#34;Select&#34; CommandName=&#34;EditDetails&#34; CommandArgument=&#39;&lt;%# Eval(&#34;userId&#34;)+&#34;$&#34;+Eval(&#34;fullName&#34;)+&#34;$&#34;+Eval(&#34;email&#34;)+&#34;$&#34;+Eval(&#34;mobile&#34;)+&#34;$&#34;+Eval(&#34;password&#34;)+&#34;$&#34;+Eval(&#34;roleId&#34;)+&#34;$&#34;+Eval(&#34;roleName&#34;) %&gt;&#39;&gt; &lt;/asp:LinkButton&gt; &lt;/ItemTemplate&gt; &lt;/asp:TemplateField&gt; &lt;/Columns&gt; &lt;/asp:GridView&gt; &lt;br /&gt; &lt;asp:TextBox runat=&#34;server&#34; ID=&#34;txtPassword&#34; TextMode=&#34;Password&#34; /&gt; &lt;asp:TextBox runat=&#34;server&#34; ID=&#34;TextBox1&#34; /&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.Net</strong></p> <pre class="brush: vb">Imports System.Data </pre> <p><span style="text-decoration: underline;"><strong>Code</strong></span></p> <p><strong>C#</strong></p> <pre class="brush: csharp">protected void Page_Load(object sender, EventArgs e) { if (!this.IsPostBack) { DataTable dt = new DataTable(); dt.Columns.AddRange(new DataColumn[] { new DataColumn(&#34;userId&#34;, typeof(int)), new DataColumn(&#34;fullName&#34;, typeof(string)), new DataColumn(&#34;email&#34;, typeof(string)), new DataColumn(&#34;mobile&#34;, typeof(string)), new DataColumn(&#34;password&#34;, typeof(string)), new DataColumn(&#34;roleId&#34;, typeof(string)), new DataColumn(&#34;roleName&#34;, typeof(string)) }); dt.Rows.Add(1, &#34;mudassar&#34;, &#34;mu@gmail.com&#34;, &#34;6565465&#34;, &#34;pass123$&#34;, &#34;r1&#34;, &#34;admin&#34;); dt.Rows.Add(2, &#34;test&#34;, &#34;mu@gmail.com&#34;, &#34;6565465&#34;, &#34;test$&#34;, &#34;r1&#34;, &#34;admin&#34;); gdvUsers.DataSource = dt; gdvUsers.DataBind(); } } protected void gdvUsers_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == &#34;EditDetails&#34;) { HiddenField hfPass = (((e.CommandSource as LinkButton).Parent.FindControl(&#34;hfPassword&#34;)) as HiddenField); txtPassword.Text = &#34;&#34;; txtPassword.Attributes.Add(&#34;value&#34;, hfPass.Value); TextBox1.Text = hfPass.Value; } }</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 Me.IsPostBack Then Dim dt As DataTable = New DataTable() dt.Columns.AddRange(New DataColumn() {New DataColumn(&#34;userId&#34;, GetType(Integer)), New DataColumn(&#34;fullName&#34;, GetType(String)), New DataColumn(&#34;email&#34;, GetType(String)), New DataColumn(&#34;mobile&#34;, GetType(String)), New DataColumn(&#34;password&#34;, GetType(String)), New DataColumn(&#34;roleId&#34;, GetType(String)), New DataColumn(&#34;roleName&#34;, GetType(String))}) dt.Rows.Add(1, &#34;mudassar&#34;, &#34;mu@gmail.com&#34;, &#34;6565465&#34;, &#34;pass123$&#34;, &#34;r1&#34;, &#34;admin&#34;) dt.Rows.Add(2, &#34;test&#34;, &#34;mu@gmail.com&#34;, &#34;6565465&#34;, &#34;test$&#34;, &#34;r1&#34;, &#34;admin&#34;) gdvUsers.DataSource = dt gdvUsers.DataBind() End If End Sub Protected Sub gdvUsers_RowCommand(ByVal sender As Object, ByVal e As GridViewCommandEventArgs) If e.CommandName = &#34;EditDetails&#34; Then Dim hfPass As HiddenField = (TryCast(((TryCast(e.CommandSource, LinkButton)).Parent.FindControl(&#34;hfPassword&#34;)), HiddenField)) txtPassword.Text = &#34;&#34; txtPassword.Attributes.Add(&#34;value&#34;, hfPass.Value) TextBox1.Text = hfPass.Value End If End Sub</pre> <p><span style="text-decoration: underline;"><strong>Screenshot</strong></span></p> <p>&nbsp;<img src="https://i.imgur.com/FExE9Mw.gif" alt="" width="472" height="222" /></p>https://www.aspforums.net:443/Threads/906603/Set-TextBox-value-when-TextMode-is-Password-on-ASPNet-GridView-RowCommand-using-C-and-VBNet/https://www.aspforums.net:443/Threads/906603/Set-TextBox-value-when-TextMode-is-Password-on-ASPNet-GridView-RowCommand-using-C-and-VBNet/Tue, 02 Jul 2019 06:43:40 GMT