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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

DropDownList have undefined value after page validation

Thread ID:

Created:

Updated:

Platform:

Replies:

127915 Dec 18,2016 05:37 PM UTC Dec 19,2016 04:47 AM UTC ASP.NET Web Forms 2
loading
Tags: DropDownList
Tomasz
Asked On December 18, 2016 05:37 PM UTC

Like in title. After the page validation dropdownlist look like lost connection with some columns from table:
This is the code:

<ej:DropDownList ID="ddlRegimen" runat="server" Width="100%" WatermarkText="Regimen" DataSourceID="SqlDataRegim" DataTextField="RegimenName" DataValueField="RegimenId"></ej:DropDownList>

<asp:SqlDataSource ID="SqlDataRegim" runat="server" ConnectionString="<%$ ConnectionStrings:dbhlpConnString %>" SelectCommand="SELECT [RegimenId], [RegimenName] FROM [Regimen]"></asp:SqlDataSource>

<asp:RequiredFieldValidator ID="RequiredFieldValidator11" runat="server" ForeColor="Red" Font-Size="12px" ErrorMessage="Select regimen for this person" InitialValue="" ControlToValidate="ddlRegimen" Display="Dynamic"></asp:RequiredFieldValidator>



Tomasz
Replied On December 18, 2016 06:15 PM UTC

ok solved :) put connection string in code behind fix the problem if is in "If(!IsPostBack):

if (!IsPostBack)

{



SqlCommand cmd = new SqlCommand("Select [CountryId], [CountryName] from [Country]", conn);

SqlDataAdapter da = new SqlDataAdapter(cmd);

DataSet ds = new DataSet();

da.Fill(ds);

conn.Open();

this.ddlcountry.DataSource = ds.Tables[0];

this.ddlcountry.DataBind();

conn.Close();

}


Prince Oliver [Syncfusion]
Replied On December 19, 2016 04:47 AM UTC

  
Hi Tomasz, 

We are glad to know your problem has solved. please let us know if you need further assistance on this. 

Regards, 
Prince 


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.

Warning Icon 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.Close Icon

;