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

Selecting a combo box value in a grid column

7 Answers 112 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Brendan Vogt
Top achievements
Rank 1
Brendan Vogt asked on 08 Jul 2008, 08:52 AM
Hi,

I have a rad combo box in one of my columns in a rad grid.  My values come from a XML data file.  The combo box consists of 3 values.  Lets say ValueA, ValueB, and ValueC.  I have the combo box already populated, so if the value comes from my data file as ValueB, then ValueB must be the selected choice.  I have this combo box in a <EditItemTemplate></EditItemTemplate>

Here is my piece of code:

<radG:GridTemplateColumn
   HeaderText="Store Locator"
   UniqueName="StoreLocator">
   <ItemTemplate>
      <asp:Label ID="StoreLocator" runat="server" Text='<%# Eval("StoreLocator") %>'></asp:Label>
   </ItemTemplate>
   <EditItemTemplate>
      <radC:RadComboBox
         ID="rcStoreLocators"
         DataSourceID="dsStoreLocators"
         DataTextField="StoreLocatorName"
         DataValueField="StoreLocatorID"
         runat="server">
      </radC:RadComboBox>
   </EditItemTemplate>
</radG:GridTemplateColumn>

Please can someone help me?

Thanks
Brendan

7 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 08 Jul 2008, 09:01 AM
Hello Brendan,

You can use Bind() expression for SelectedValue:

<radC:RadComboBox
         ID="rcStoreLocators"
         DataSourceID="dsStoreLocators"
         DataTextField="StoreLocatorName"
         DataValueField="StoreLocatorID"
         SelectedValue='<%# Bind("YourFieldName") %>'
         runat="server">
      </radC:RadComboBox>


Best wishes,
Vlad
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Brendan Vogt
Top achievements
Rank 1
answered on 08 Jul 2008, 09:34 AM
Hi Vlad,

There is no SelectedValue option.

Brendan
0
Vlad
Telerik team
answered on 08 Jul 2008, 10:35 AM
Hello Brendan,

You can use Bind() expression for SelectedValue:

<radC:RadComboBox
         ID="rcStoreLocators"
         DataSourceID="dsStoreLocators"
         DataTextField="StoreLocatorName"
         DataValueField="StoreLocatorID"
         SelectedValue='<%# Bind("YourFieldName") %>'
         runat="server">
      </radC:RadComboBox>


Best wishes,
Vlad
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Brendan Vogt
Top achievements
Rank 1
answered on 08 Jul 2008, 10:38 AM
Hi Vlad,

Didn't you get my previous posting?  I got the same answer 3 times.

There is no SelectedValue option.  I am using version 2007 Q4.

Brendan
0
Shinu
Top achievements
Rank 2
answered on 08 Jul 2008, 10:43 AM
Hi Brendan,

I have tried the SelectedValue property for the RadComboBox on my end. It will not get displayed through the intellisence,  but you can directly type and bind as shown above.

Thanks
Shinu
 
0
Brendan Vogt
Top achievements
Rank 1
answered on 08 Jul 2008, 11:22 AM
Hi Shinu,

Here is my changed code.  You understand what I am trying to do?  When the edit button is clicked on a row it loads all the values into textboxes and other controls for editing.  This column is a dropdown.  The dropdown is populated from an XML datasource.  Now I want the current value in the row and make the drop down selection equal to that. 

<radC:RadComboBox
   ID="rcStoreLocators"
   DataSourceID="dsStoreLocators"
   DataTextField="StoreLocatorName"
   DataValueField="StoreLocatorID"
   SelectedValue='<%# Bind("StoreLocatorName") %>'
   Skin="WindowsGray"
   runat="server">
</radC:RadComboBox>


When I run the code like this then I get an error.  It says to me that:

DataBinding: 'System.Web.UI.WebControls.XmlDataSourceNodeDescriptor' does not contain a property with the name 'StoreLocatorName'.

This is what my StoreLocators.xml looks like:

<?xml version="1.0" encoding="utf-8" ?>
<StoreLocators>
  <StoreLocator StoreLocatorID="ShopriteAlberton" StoreLocatorName="Shoprite Alberton" />
  <StoreLocator StoreLocatorID="ShopriteBloemfontein" StoreLocatorName="Shoprite Bloemfontein" />
  <StoreLocator StoreLocatorID="ShopritePaarl" StoreLocatorName="Shoprite Paarl" />
</StoreLocators>


Please can some one help me in my confusion?

THanks
Brendan
0
Vlad
Telerik team
answered on 08 Jul 2008, 02:31 PM
Hello Brendan,

You can use XPath similar to this example:
http://quickstarts.asp.net/QuickStartv20/util/srcview.aspx?path=~/aspnet/samples/data/DataListXmlNested.src

Greetings,
Vlad
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Grid
Asked by
Brendan Vogt
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Brendan Vogt
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Share this question
or