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

Dropdownlist in a FormTemplate

2 Answers 117 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 26 Aug 2008, 11:07 AM
Hi,

I am struggling with my dropdownlist in my FormTemplate.  When I click on the Insert link it populates the dropdownlist just fine.

<radcb:RadComboBox
   ID="rcbTitles"
   AppendDataBoundItems="true"
   DataSourceID="odsTitles"
   DataTextField="Description"
   DataValueField="TitleID"
   Skin="WindowsGray"
   SelectedValue='<%# Bind("Titles") %>'
   runat="server">
   <Items>
      <radcb:RadComboBoxItem Text="Select" Value="" />
   </Items>
</radcb:RadComboBox>


My ItemCommand looks like:

if (e.CommandName == RadGrid.InitInsertCommandName)
{
   e.Canceled = true;

   ListDictionary newValues = new ListDictionary();
   newValues["Titles"] = "";
   //Insert the item and rebind
   e.Item.OwnerTableView.InsertItem(newValues);
}


I am using a FormTemplate.  I am not understanding my error, I have been struggling for 2 days, is there no one on this forum that can help me?  When I click on the Insert link and click cancel I get the following error:

DataBinding: 'Telerik.WebControls.GridInsertionObject' does not contain a property with the name 'Titles'.

What am I doing wrong?  Please can some try and help me??

Thanks
Brendan

2 Answers, 1 is accepted

Sort by
0
Brendan Vogt
Top achievements
Rank 1
answered on 26 Aug 2008, 01:41 PM
My grid is loaded like this:

private void LoadCommunication()
{
   int _ClientId = Int32.Parse(Request.QueryString["ClientId"]);
   List<Communication> communications = CommunicationManager.QueryCommunicationsByClientId(_ClientId);

   rgCommunications.DataSource = communications;
   rgCommunications.DataBind();
}

In each Communication class there is a reference to the Title class.  So if I need to access the the TitleID property, then it would be something like:

Communication.Title.TitleID

The object datasource in my .aspx file to load the titles looks like:

<asp:ObjectDataSource
   ID="odsTitles"
   TypeName="Nedbank.Excon.Lookup.TitleManager"
   SelectMethod="GetTitles"
   runat="server">
</asp:ObjectDataSource>


I know that my error is here:

SelectedValue='<%# Bind("Titles") %>'

..but I do not know how to fix it, or make it work.  There is no Titles property.  I'm assuming they are looking for the Title.TitleID?  This does not work in Bind("Title.TitleID").  I did read the sample applications.

Please can someone advise..
0
Sebastian
Telerik team
answered on 29 Aug 2008, 10:18 AM
Hi Brendan,

You can easily bypass the error by setting AppendDataBoundItems = true for RadComboBox and including an empty item to its Items collection. Review the third paragraph of this documentation article for more details:

http://www.telerik.com/help/aspnet-ajax/grderrormessages.html

Additionally, I recommend you use advanced binding for your grid by intercepting the NeedDataSource event.

Best regards,
Stephen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Brendan Vogt
Top achievements
Rank 1
Answers by
Brendan Vogt
Top achievements
Rank 1
Sebastian
Telerik team
Share this question
or