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 DropDownList selected value on ASP.Net GridView Edit Button Click using C# and VB.Net<p>Hi <a class="username" rel="itsme"> itsme</a>,</p> <p>Refer below link -</p> <h1 class="header"><a title="Populate DropDownList with Selected Value in EditItemTemplate of GridView in ASP.Net'a" href="https://www.aspsnippets.com/Articles/Populate-DropDownList-with-Selected-Value-in-EditItemTemplate-of-GridView-in-ASPNet.aspx">Populate DropDownList with Selected Value in EditItemTemplate of GridView in ASP.Net</a></h1>https://www.aspforums.net:443/Threads/190240/Set-DropDownList-selected-value-on-ASPNet-GridView-Edit-Button-Click-using-C-and-VBNet/https://www.aspforums.net:443/Threads/190240/Set-DropDownList-selected-value-on-ASPNet-GridView-Edit-Button-Click-using-C-and-VBNet/Tue, 30 Jul 2019 00:17:42 GMTSet DropDownList selected value on ASP.Net GridView Edit Button Click using C# and VB.Net<p>Hey</p> <p>I found the answer and it is working</p> <p>Thanks</p> <pre class="brush: csharp"> protected void btnEdit_Click(object sender, EventArgs e) { try { Button btn = sender as Button; GridViewRow grow = btn.NamingContainer as GridViewRow; Id.Value = (grow.FindControl(&#34;Id&#34;) as Label).Text; Image img = (grow.FindControl(&#34;img&#34;) as Image); txt_email.Text = (grow.FindControl(&#34;lblemail&#34;) as Label).Text; txt_link.Text = (grow.FindControl(&#34;lblweb&#34;) as Label).Text; txt_img.Text = (grow.FindControl(&#34;lblimg&#34;) as Label).Text; txt_name.Text = (grow.FindControl(&#34;lblname&#34;) as Label).Text; txt_pay.Text = (grow.FindControl(&#34;lblpay&#34;) as Label).Text; txt_toll.Text = (grow.FindControl(&#34;lbltoll&#34;) as Label).Text; txt_Address.Text = (grow.FindControl(&#34;lblAddress&#34;) as Label).Text; Image1.ImageUrl = img.ImageUrl; btnUpdate.Visible = true; string value = (grow.FindControl(&#34;lblBname&#34;) as Label).Text; DropDownList1.ClearSelection(); DropDownList1.Items.FindByText(value).Selected = true; string value2 = (grow.FindControl(&#34;lblcity&#34;) as Label).Text; DropDownList2.ClearSelection(); DropDownList2.Items.FindByValue(value2).Selected = true; string from = (grow.FindControl(&#34;lblopen&#34;) as Label).Text; string[] parts = from.Split(&#39;,&#39;); //string to = (grow.FindControl(&#34;lblopen&#34;) as Label).Text; ddlTimeFrom.ClearSelection();ddlTimeTo.ClearSelection(); ddlTimeFrom.Items.FindByValue(parts[0].Trim()).Selected = true; ddlTimeTo.Items.FindByValue(parts[1].Trim()).Selected = true; } catch(Exception ex) { Response.Write(ex); } }</pre> <p>&nbsp;</p>https://www.aspforums.net:443/Threads/190240/Set-DropDownList-selected-value-on-ASPNet-GridView-Edit-Button-Click-using-C-and-VBNet/https://www.aspforums.net:443/Threads/190240/Set-DropDownList-selected-value-on-ASPNet-GridView-Edit-Button-Click-using-C-and-VBNet/Tue, 30 Jul 2019 21:08:57 GMT