views:

543

answers:

2

I believe it's irrelevant of what type of combo box i'm using, but I'm using a Rad Combo Box. My data source not only selects data for the Data Text Field and Value Field but it also selects a couple of other columns. I want to get the values of those columns for the selected Item. How can i accomplish this on selectedindexchanged?

 <table width="100%">
                <tr>
                    <td align="center" ><strong>Please select a policy :</strong>
                        <telerik:RadComboBox ID="RadComboPolicy" runat="server" Width="400px"  OnSelectedIndexChanged="RadComboPolicy_SelectedIndexChanged"  DataSourceID="SqlDataSource2" AppendDataBoundItems="true" DataTextField="Pname" AutoPostBack="true" DataValueField="PID">
                        <Items>
                            <telerik:RadComboBoxItem runat="server" Selected="true" Value="-1" Text="Select a Policy to Begin" />
                        </Items>
                        </telerik:RadComboBox>
                        <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
                            ConnectionString="<%$ConnectionString %>" SelectCommand="select p.pid,p.pname,p.startdate,p.enddate from insurance..policy p">
                        </asp:SqlDataSource>
                    </td>
                </tr>
            </table>



 protected void RadComboPolicy_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
{
    //Here i want to get the startdate and enddate
}
A: 

You need to put the data somewhere. This could be a hidden field (like a literal with display=false). Then you can get the RadComboItem's row and find the hidden fields and parse the dates out of there.

statichippo
How can i put the data in a hidden field being that i can only set that hidden field value after a value is selected on selected index changed???
Eric
+1  A: 

As your code stands right now, you're basically throwing out the startdate and enddate data when you bind pid and pname to the combo box. You'll either need to store this data in a hidden field (as statichippo stated) or pull the information out of the database using the pid on the server-side.

In any case, as it stands now, this data isn't available anywhere during the post-back.

krohrbaugh
how can i store selected data in a hidden field on client side?
Eric
I pulled information on server side using selected value since it was the primary key.
Eric