This is a migrated thread and some comments may be shown as answers.

Multiple ComboBoxes in RadGrid

2 Answers 96 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
towpse
Top achievements
Rank 2
towpse asked on 16 Oct 2008, 05:02 PM
Hey folks.

I have a grid that may contain 0 or more combo boxes in one of the coumns of each row.

What I am trying to do is validate the data held by each combo when the form is submitted.

Originally I had this:

<telerik:GridTemplateColumn UniqueName="DataValue" DataField="DataValue" SortExpression="DataValue" HeaderText="<%$ Resources:Default, DATA_VALUE_HEADER_TEXT %>">  
 
<EditItemTemplate> 
 
<asp:TextBox    ID="txtDataValue"   
runat="server" Text='<%# DataBinder.Eval(Container,"DataItem.DataValue") %>' 
Width="150px">  
</asp:TextBox> 
 
<asp:RequiredFieldValidator      
ID="rf_txtDataValue"   
runat="server" 
ErrorMessage = "You must enter a value" 
Text = "*" 
Enabled="false" 
Visible"true" 
ControlToValidate="txtDataValue" 
Display="Dynamic"/>  
 
<asp:DropDownList ID="ddlDataValue"   
runat="server"   
Width="155px"></asp:DropDownList>                                         
 
<asp:RequiredFieldValidator     ID="rf_ddlDataValue"   
runat="server" 
ErrorMessage = "You must select a value" 
Text = "*" 
Enabled="false" 
Visible"true" 
InitialValue ="<%$ Resources:Default, DEFAULT_LIST_ITEM_VALUE %>" 
ControlToValidate="ddlDataValue" 
Display="Dynamic" /> 
 
</EditItemTemplate> 
</telerik:GridTemplateColumn> 

I want to change the drop down list to a telerik combo box. Items will inserted into the combo box dynamically.
I'd like to validate the selection using some kind of validator. I saw examples of validating telerik combos using custom validators.

If I use custom validators it seems like I could use one validator where the validator method could simply iterate through the grid looking to see if a combo is enabled in the row and then check to see if it has a valid value; if not it could set the text of a label that sits beside the combo, using find control of the row, to a red * or something.

A nicer implementation might be, I would think, if each combo had it's own custom validator where the validator method can get the client side instance of the telerik combo that it is set to validate; or the combo that is in the same grid row as the validator that is doing the validation. That way if it is invalid the validator will simply show itself as a red *. Can the custom validator get a specific instance of a combo? Is this solution possible?


Thanks.

mat.t.

2 Answers, 1 is accepted

Sort by
0
Accepted
Blaize
Top achievements
Rank 1
answered on 17 Oct 2008, 12:45 PM
Hey mat.t.,

I think the "prometheus" combo supports validation out of the box? At least their example is showing that:
http://demos.telerik.com/aspnet/prometheus/Combobox/Examples/Functionality/Validation/DefaultCS.aspx

Cheers,
Blaiz


0
towpse
Top achievements
Rank 2
answered on 17 Oct 2008, 10:45 PM
Right on. Thanks, man. That's perfect. Never came across that compare validator sample but it seems obvious enough. very cool.

I was trying with the custom validator and in that case I would need to know which combo box was being validated probably by looping through that colleciton of combos.

In this case I let the compare validator worrry about that. Excellent.

Cheers.
Tags
ComboBox
Asked by
towpse
Top achievements
Rank 2
Answers by
Blaize
Top achievements
Rank 1
towpse
Top achievements
Rank 2
Share this question
or