Hello,
I have a combo box inside a GridTableView. It is populated on demand (Load on demand)
I want to make that ComboBox the other two TextBox controls to be populated with appropriate data when the ComboBox's index is changed.
How do i do that?
Thank you so much
I have a combo box inside a GridTableView. It is populated on demand (Load on demand)
I want to make that ComboBox the other two TextBox controls to be populated with appropriate data when the ComboBox's index is changed.
How do i do that?
Thank you so much
5 Answers, 1 is accepted
0
Accepted
Princy
Top achievements
Rank 2
answered on 19 Mar 2014, 05:13 AM
Hi Jugoslav,
I guess you want to have a TextBox populated on the RadComboBox OnSelectedIndexChanged event in RadGrid edit mode. Please have a loo at the following code snippet.
ASPX:
C#:
Thanks,
Princy
I guess you want to have a TextBox populated on the RadComboBox OnSelectedIndexChanged event in RadGrid edit mode. Please have a loo at the following code snippet.
ASPX:
<telerik:GridTemplateColumn HeaderText="CompanyName"> <ItemTemplate> <%# Eval("CompanyName") %> </ItemTemplate> <EditItemTemplate> <telerik:RadComboBox ID="RadComboBox1" runat="server" EnableLoadOnDemand="true" AllowCustomText="true" ShowMoreResultsBox="true" MaxHeight="220px" AutoPostBack="true" Filter="StartsWith" OnItemsRequested="RadComboBox1_ItemsRequested" OnSelectedIndexChanged="RadComboBox1_SelectedIndexChanged"> </telerik:RadComboBox> </EditItemTemplate></telerik:GridTemplateColumn><telerik:GridTemplateColumn EditFormHeaderTextFormat="TextBox"> <EditItemTemplate> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> </EditItemTemplate></telerik:GridTemplateColumn>C#:
protected void RadComboBox1_ItemsRequested(object sender, Telerik.Web.UI.RadComboBoxItemsRequestedEventArgs e){ RadComboBox combo = (RadComboBox)sender; String connstring = WebConfigurationManager.ConnectionStrings["Northwind_newConnectionString3"].ConnectionString; SqlConnection conn = new SqlConnection(connstring); SqlDataAdapter adapter = new SqlDataAdapter(); adapter.SelectCommand = new SqlCommand("SELECT * from Customers WHERE CompanyName LIKE '" + e.Text + "%'", conn); DataTable data = new DataTable(); conn.Open(); try { adapter.Fill(data); } finally { conn.Close(); } combo.DataSource = data; combo.DataTextField = "CompanyName"; combo.DataValueField = "CompanyName"; combo.DataBind();}protected void RadComboBox1_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e){ RadComboBox combo = (RadComboBox)sender; GridEditableItem edititem = (GridEditableItem)combo.NamingContainer; string selectedvalue = combo.SelectedValue; TextBox txt = (TextBox)edititem.FindControl("TextBox1"); //Access the TextBox txt.Text = selectedvalue;}Thanks,
Princy
0
Jugoslav
Top achievements
Rank 1
answered on 19 Mar 2014, 07:07 AM
Unhandled exception at line 15, column 16485 in http://localhost:49573/Telerik.Web.UI.WebResource.axd?_TSM_HiddenField_=RadScriptManager1_TSM&compress=1&_TSM_CombinedScripts_=;;System.Web.Extensions,+Version=4.0.0.0,+Culture=neutral,+PublicKeyToken= ....<br><br>0x800a139e - JavaScript runtime error: Sys.WebForms.PageRequestManagerServerErrorException: Object reference not set to an instance of an object.Any ideas why it happens?
0
Jugoslav
Top achievements
Rank 1
answered on 19 Mar 2014, 07:13 AM
protected void Medications_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e) { RadComboBox combo = (RadComboBox)sender; GridEditableItem edititem = (GridEditableItem)combo.NamingContainer; TextBox BookTitleEdit = edititem.FindControl("BookTitleEdit") as TextBox; if (BookTitleEdit != null) { BookTitleEdit.Text = "OK"; // combo.SelectedValue; } }Meaning, the combobox rises the event but the textbox control seems to be not found in the code. Thanks again
0
Hi Jugoslav,
Could you please elaborate more on what EditMode does the grid use? If it uses Batch I suggest moving the populating logic on the client(because if a postback is triggered from the combo the changes will be lost).
Note that it would be best to provide us with the markup and code-behind of the page so we could examine the scenario. That would greatly facilitate us in providing a more precise answer.
Regards,
Angel Petrov
Telerik
Could you please elaborate more on what EditMode does the grid use? If it uses Batch I suggest moving the populating logic on the client(because if a postback is triggered from the combo the changes will be lost).
Note that it would be best to provide us with the markup and code-behind of the page so we could examine the scenario. That would greatly facilitate us in providing a more precise answer.
Regards,
Angel Petrov
Telerik
Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET.. Seats are limited.
0
Jugoslav
Top achievements
Rank 1
answered on 25 Mar 2014, 05:23 PM
Oh no the Princy's answer helped me to sort this thing out ... i marked his reply as answer already.
It was my mistake when i was testing his code refering TextBox instead RadTextBox ... as soon as i changed that it worked like a charm.
Thank you so much anyway
It was my mistake when i was testing his code refering TextBox instead RadTextBox ... as soon as i changed that it worked like a charm.
Thank you so much anyway