We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

How do I set the dropdownlist selected value on the server page laod event?

Thread ID:

Created:

Updated:

Platform:

Replies:

119711 Jul 23,2015 11:17 AM Sep 28,2016 06:39 AM ASP.NET Web Forms 3
loading
Tags: DropDownList
David Farmer
Asked On July 23, 2015 11:17 AM

Hi, I'm using the asp.net DropDownList control bound to a sql data source

<ej:DropDownList ID="DropDownList" runat="server" DataSourceID="sqlGroups" DataTextField="fldGroup" DataValueField="fldGroup">

</ej:DropDownList>

On the server page load event I want to find a value in the dropdownlist and select it.

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

If Not IsPostBack Then

   Dim strGroup As New Syncfusion.JavaScript.Web.DropDownListItem


   strGroup.Text = "test text"

   strGroup.Value = "test value"

  DropDownList.SelectedItemIndex = DropDownList.Items.FindIndex(strGroup)



End If

End Sub

I guess it will be something like this


Ezhil S [Syncfusion]
Replied On July 27, 2015 12:45 PM

Hi David,

Sorry about the inconvenience caused.

Currently it is not possible to access Items from code behind when data bound with DataSource in DropDownList control. We have internally logged this issue, and fix will be included in our upcoming SP1 release which is planned to roll-out in the end of July , 2015

Please let us know if you have any queries.


Regards,

Ezhil S


Oscar Daniel Vega Castaneda
Replied On September 27, 2016 11:39 AM

Ezhil S

Hi, this issues was solved?, I'm using Syncfusion 2016 Vol 1 (14.1.0.41) and I can't set value to dropdownlist. How I can do that?



Kasithangam C [Syncfusion]
Replied On September 28, 2016 06:39 AM

Hi David, 
 
Yes, the reported issue has been fixed in 2016 Vol 1 (14.1.0.41). We have a property called “value” which is used to specify the value for DropDownList control. Please find the code for same: 
 
<code> 
 
  protected void Page_Load(object sender, EventArgs e) 
        { 
            DrpDwnsql.Value = "Waterways"; 
        } 
 
 
<code> 
 
We have prepared the sample based on your requirement and it is available under the following link: 
 
Sample: Sample 
 
Regards, 
Kasithangam 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;