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. Image for the cookie policy date

DropDownList have undefined value after page validation

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>



2 Replies

TO Tomasz 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();

}



PO Prince Oliver Syncfusion Team 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 


Loader.
Up arrow icon