4 Answers, 1 is accepted
0

Shinu
Top achievements
Rank 2
answered on 23 Jan 2009, 10:19 AM
Hi Parodist,
I hope you want to use RequireFieldValidator for validating the RadComboBox. In that case you can set the InitialValue of the RequireFieldValidator to -Select- for excluding the item from validation.
ASPX:
Thanks,
Shinu.
I hope you want to use RequireFieldValidator for validating the RadComboBox. In that case you can set the InitialValue of the RequireFieldValidator to -Select- for excluding the item from validation.
ASPX:
<telerik:RadComboBox ID="RadComboBox1" Runat="server"> |
<Items> |
<telerik:RadComboBoxItem runat="server" Text="-Select-" Value="-Select-"/> |
<telerik:RadComboBoxItem runat="server" Text="RadComboBoxItem1" |
Value="RadComboBoxItem1" /> |
<telerik:RadComboBoxItem runat="server" Text="RadComboBoxItem2" |
Value="RadComboBoxItem2" /> |
</Items> |
</telerik:RadComboBox> |
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="RadComboBox1" ErrorMessage="Value cannot be empty" InitialValue="-Select-"></asp:RequiredFieldValidator> |
Thanks,
Shinu.
0

Parodist
Top achievements
Rank 1
answered on 23 Jan 2009, 10:36 AM
Thanks for the reply Shinu,I display the RadComboBox item from the database on page load
How can I have the --select-- option with required field validators ?
if (!IsPostBack) |
{ |
string Query = ""; |
DataTable dt = null; |
Query = "SELECT ActivityId,ActivityType FROM ScheduleActivityMaster"; |
dt = objDataLayer.GetDataTable(Query); |
RadComboBox1.DataSource = dt; |
RadComboBox1.DataTextField = "ActivityType"; |
RadComboBox1.DataValueField = "ActivityId"; |
RadComboBox1.DataBind(); |
} |
0

Parodist
Top achievements
Rank 1
answered on 23 Jan 2009, 10:42 AM
Hi Shinu ,
I got it working by adding
I got it working by adding
RadComboBox1.Items.Insert(0,
new RadComboBoxItem("----Select----", "0")); but how would I add required field validator ?
Thanking you.
0

Shinu
Top achievements
Rank 2
answered on 23 Jan 2009, 01:12 PM
Hello Parodist,
I guess you are trying to add the RequiredFieldValidator control dynamically. You can try the below code snippet for adding the control dynamically.
CS:
Thanks,
Shinu.
I guess you are trying to add the RequiredFieldValidator control dynamically. You can try the below code snippet for adding the control dynamically.
CS:
protected void Page_Load(object sender, EventArgs e) |
{ |
RequiredFieldValidator RequiredFieldValidator1 = new RequiredFieldValidator(); |
RequiredFieldValidator1.ControlToValidate = "RadComboBox1"; |
RequiredFieldValidator1.ErrorMessage = "Value cannot be empty"; |
RequiredFieldValidator1.InitialValue = "-Select-"; |
this.form1.Controls.Add(RequiredFieldValidator1); |
} |
Thanks,
Shinu.