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

Convert data type of input parameter

3 Answers 140 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
William Corry
Top achievements
Rank 1
William Corry asked on 08 Apr 2009, 08:59 PM
I have two comboboxes on a web form.  The first combobox returns a date in the form of a string.  The datasource of the second combobox is a stored procedure that requires a datetime input parameter.  I would like to use the first combobox as the source of the input parameter for the second combobox but the datatype is wrong.  Is there anyway that it is possible to convert the datatype of first combobox -- that is without having to rewrite the stored procedure.  Something like:

<%@ Control Language="VB" AutoEventWireup="false" CodeFile="AllTab115Instances.ascx.vb" Inherits="AllInstances" %>  
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>  
<telerik:RadComboBox ID="RadComboBox1" runat="server"   
    DataSourceID="SqlDataSource1" DataTextField="Instance_name"   
    DataValueField="Instance_name" Width="110px">  
<CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>  
</telerik:RadComboBox>  
<asp:TextBox ID="txtNotBeforeDate" runat="server" Visible="False"></asp:TextBox>  
<asp:SqlDataSource ID="SqlDataSource1" runat="server"   
    ConnectionString="<%$ ConnectionStrings:ActiveString %>"   
    SelectCommand="stdprc_GetAllTab115Instances"   
    SelectCommandType="StoredProcedure">  
    <SelectParameters>  
        <asp:ControlParameter ControlID="txtNotBeforeDate"      DefaultValue="1/1/1900"   
            Name="NotBefore" 
            --the next line is where I would think you might convert type?  
        PropertyName=Ctype("Text",dateTime)   
 
         Type="DateTime" />  
    </SelectParameters>  
</asp:SqlDataSource> 

I also have a second question.  Is there a way to programmatically select the first item in the first combobox when the page initially opens?

3 Answers, 1 is accepted

Sort by
0
Simon
Telerik team
answered on 13 Apr 2009, 08:50 AM
Hello William Corry,

You could directly use the Text property of the TextBox in the Select Parameter definition. The String value in the Text will be automatically converted to DateTime.

So, instead of PropertyName=Ctype("Text",dateTime) please try using PropertyName="Text".

Regarding your second question, in case the RadComboBox is read-only (as in your case) it automatically selects the first Item in its list if not specified otherwise. So, in your case the first Item will be selected when the page loads.

Please try implementing the first suggestion and write here if any issues arise.

Greetings,
Simon
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
0
William Corry
Top achievements
Rank 1
answered on 13 Apr 2009, 01:15 PM
Thanks,  seems to work well on all suggestions.
0
Simon
Telerik team
answered on 13 Apr 2009, 01:30 PM
Hello William Corry,

This is good, thank you for the follow up.

In case you have additional questions or you need assistance with our products, please feel free to write to us via a support ticket or in the forums. We will be glad to assist you.

Regards,
Simon
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
Tags
ComboBox
Asked by
William Corry
Top achievements
Rank 1
Answers by
Simon
Telerik team
William Corry
Top achievements
Rank 1
Share this question
or