Hi,
I used the TextBoxTemplate which Nick provided.. in my code.. In my case, am creating the radcombo dynamically from code behind.. and adding the item template also dynamically from code behind. But its not displaying the values, Instead it creates text boxes with out any text.. And I want to set the the Initial value also like 'Select one'.. Its displaying "System.Data.DataRowView" in DropDown.. If I click it is displaying textboxes without text.. How can I solve this..
In designing we can give like <asp:TextBox id="text1" runat="server" Text='<%=Eval("Name") %>' />.. Like that how to do for text box in template of rad combo in code behind c#
class TextBoxTemplate : ITemplate |
{ |
string ColName = "Text"; |
public void InstantiateIn(Control container) |
{ |
TextBox textBox = new TextBox(); |
textBox.ID = "tabTextBox"; |
textBox.DataBinding += new EventHandler(this.txt_DataBind); |
container.Controls.Add(textBox); |
} |
public void txt_DataBind(Object sender, EventArgs e) |
{ |
TextBox txt = (TextBox)sender; |
RadComboBoxItem radCombo = (RadComboBoxItem)txt.NamingContainer; |
txt.Text = DataBinder.Eval(radCombo, ColName).ToString(); |
} |
} |
/*-------------- Dynamic creation of rad combo----------------*/ |
RadComboBox RadDropDownShopper = new RadComboBox(); |
RadDropDownShopper.ID = "RadDropdownShopper" + i.ToString(); |
RadDropDownShopper.Attributes.Add("style", "padding-top: 8px;"); |
RadDropDownShopper.Attributes.Add("style", "padding-left: 30px;"); |
RadDropDownShopper.ItemTemplate = new TextBoxTemplate(); |
RadDropDownShopper.DataSource = FakeDataTable(); |
RadDropDownShopper.DataBind(); |
("Select Shopper/Member")); |
tdShopper.Controls.Add(RadDropDownShopper); |
Thanks in advance
Nimmi