Hi all,
I have also tried:
I have been playing around with the possibility of enabling users to enter a new url into a radcombobox if it doesn't exist in list already. I have the following markup in my grid <FormTemplate> which pulls its data from a table named tblUrls:
<telerik:RadComboBox ID="UrlComboBox" |
runat="server" |
HighlightTemplatedItems="true" |
AllowCustomText="true" |
Skin="Windows7" |
Width="365px" |
Height="150px" |
DataSourceID="UrlDataSource" |
DataTextField="Url" |
DataValueField="Url" |
SelectedValue='<%# Bind("Url") %>' |
AppendDataBoundItems="true"> |
<Items> |
<telerik:RadComboBoxItem Text="[Not Defined]" Value="" /> |
</Items> |
<FooterTemplate> |
<telerik:RadTextBox ID="tbNewUrl" runat="server" Skin="Windows7" EmptyMessage="Add a new Url here..."/> |
<br /> |
<asp:Button ID="AddUrlBtn" runat="server" Text="Add Url" OnClick="AddUrlBtn_Click" /> |
</FooterTemplate> |
</telerik:RadComboBox> |
I have tried getting access to the tbNewUrl radtextbox inside the RadComboBox in the c# code behind to no avail. I need the AddUrlBtn_Click to save whatever value is put in by the user to the database when the grid is in insert or edit mode. I have the database INSERT code already worked out but getting access to the RadComboBox and the newly inputted url data is proving to be a real pain. I am sure it is real simple, but patience has run out on this one and I am forced to try another way of doing this if I can;t get it resolved quickly.
I have tried:
protected void AddUrlBtn_Click(object sender, EventArgs e) |
{ |
TextBox Urltxt = (TextBox)UrlComboBox.Footer.FindControl("tbNewUrl"); |
if ((!String.IsNullOrEmpty(Urltxt.Text))&&(UrlComboBox.FindItemByText(Urltxt.Text) == null)) |
{ |
UrlComboBox.Items.Insert(0, new RadComboBoxItem(Urltxt.Text)); |
UrlComboBox.SelectedIndex = 0; |
Urltxt.Text = String.Empty; |
} |
} |
I have also tried:
TextBox AddUrlText = (TextBox)this.Page.Master.FindControl("ContentPlaceHolder").FindControl("tbNewUrl"); |
inside the buttons click event - AddUrlBtn_Click but it can't find the control???
The grid is ajaxified too but when I click the AddUrlBtn in its current condition the page does a full postback as well whilst in insert/edit mode which is undesirable.
Any help with this would be greatly appreciated to I can move on with this project.
Thanks in advance for any help :)