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.

DropDownList have undefined value after page validation

Thread ID:

Created:

Updated:

Platform:

Replies:

127915 Dec 18,2016 12:37 PM Dec 18,2016 11:47 PM ASP.NET Web Forms 2
loading
Tags: DropDownList
Tomasz
Asked On December 18, 2016 12:37 PM

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 01:15 PM

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 18, 2016 11:47 PM

  
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.

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.

;