bradley baker
Top achievements
Rank 1
bradley baker
asked on 20 Nov 2009, 05:46 PM
I have a ComboBox that is hidden and I want to get the Text value of it not the SelectedValue. RadComboBox1.Text will work if the combobox ISNT hidden but once you hide it the value is then blank.
ComboBox0 Passes the selected value to ComboBox1 (hidden) I then want to store the text of this combobox in a database now.
ComboBox0 Passes the selected value to ComboBox1 (hidden) I then want to store the text of this combobox in a database now.
4 Answers, 1 is accepted
0
Shinu
Top achievements
Rank 2
answered on 23 Nov 2009, 08:42 AM
Hello Bradley Baker,
I am not sure about the scenario that you are trying. I tried accessing the Text property of RadComboBox and it is working fine in my end even if the combo is hidden (I am using RadControls for ASP.NET Ajax version 2009, 3, 1103, 35 ).
Here is the code that I tried:
ASPX:
C#:
Have you tried "RadComboBox1.SelectedItem.Text" ?
-Shinu.
I am not sure about the scenario that you are trying. I tried accessing the Text property of RadComboBox and it is working fine in my end even if the combo is hidden (I am using RadControls for ASP.NET Ajax version 2009, 3, 1103, 35 ).
Here is the code that I tried:
ASPX:
| <telerik:RadComboBox ID="RadComboBox1" runat="server" AutoPostBack="True" OnSelectedIndexChanged="RadComboBox1_SelectedIndexChanged"> |
| <Items> |
| <telerik:RadComboBoxItem runat="server" Text="RadComboBoxItem1" Value="RadComboBoxItem1"> |
| </telerik:RadComboBoxItem> |
| . . . |
| </Items> |
| </telerik:RadComboBox> |
C#:
| protected void Button1_Click(object sender, EventArgs e) |
| { |
| RadComboBox1.Visible = false; |
| RadComboBox1.SelectedValue = RadComboBox1.SelectedValue; |
| Response.Write(RadComboBox1.SelectedValue); |
| Response.Write(RadComboBox1.SelectedItem.Text); |
| Response.Write(RadComboBox1.Text); |
| } |
Have you tried "RadComboBox1.SelectedItem.Text" ?
-Shinu.
0
bradley baker
Top achievements
Rank 1
answered on 23 Nov 2009, 03:48 PM
| RadComboBox2.SelectedItem.Text |
| <tr> |
| <td width="100px"> |
| <asp:Label ID="Label2" runat="server" Text="Reason"></asp:Label> |
| </td> |
| <td> |
| <telerik:RadComboBox ID="RadComboBox1" Runat="server" AutoPostBack="true" |
| DataSourceID="COReasonDDSQL" DataTextField="coreason_name" OnSelectedIndexChanged="RadComboBox1_SelectedIndexChanged" |
| DataValueField="coreason_id" MarkFirstMatch="True" AllowCustomText="true" EmptyMessage="Select One"> |
| </telerik:RadComboBox> |
| <telerik:RadComboBox ID="RadComboBox2" Runat="server" Visible="false" |
| DataSourceID="PlnrSQL" DataTextField="Column1" |
| DataValueField="PBPBC" MarkFirstMatch="True" AllowCustomText="True" |
| EmptyMessage="Select One"> |
| </telerik:RadComboBox> |
| <telerik:RadComboBox ID="RadComboBox3" Runat="server" Visible="false" |
| DataSourceID="COReasonDDSQL" DataTextField="coreason_start" |
| DataValueField="coreason_id" MarkFirstMatch="True" AllowCustomText="True" |
| EmptyMessage="Select One"> |
| </telerik:RadComboBox> |
| <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" |
| ErrorMessage="Required" ControlToValidate="RadComboBox1"></asp:RequiredFieldValidator> |
| </td> |
| </tr> |
| Imports Telerik.Web.UI |
| Partial Class sales_change_order_co_add |
| Inherits System.Web.UI.Page |
| Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click |
| CORequest.Insert() |
| End Sub |
| Protected Sub RadComboBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As RadComboBoxSelectedIndexChangedEventArgs) |
| If RadComboBox1.SelectedItem IsNot Nothing Then |
| RadComboBox3.SelectedValue = RadComboBox1.SelectedValue |
| End If |
| End Sub |
| Protected Sub CORequest_Inserting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceCommandEventArgs) Handles CORequest.Inserting |
| Dim PlannerBox As String = RadComboBox2.Text |
| Dim Planner As String |
| Dim PlannerSplit As String() |
| Dim WhereAt As String = RadComboBox3.Text |
| PlannerSplit = PlannerBox.Split("@") |
| Planner = String.Concat("CORP\", PlannerSplit(0).ToLower) |
| e.Command.Parameters("@DMD").Value = RadTextBox1.Text |
| e.Command.Parameters("@REQUESTOR").Value = Context.User.Identity.Name.ToString() |
| e.Command.Parameters("@REASON").Value = RadComboBox1.SelectedValue |
| e.Command.Parameters("@SHIPTO").Value = RadTextBox2.Text + "" |
| e.Command.Parameters("@LINENO").Value = RadTextBox3.Text |
| e.Command.Parameters("@QTY").Value = RadTextBox4.Text |
| e.Command.Parameters("@PARTNO").Value = RadTextBox5.Text + "" |
| e.Command.Parameters("@UNITPRICE").Value = RadTextBox6.Text |
| e.Command.Parameters("@NOTES").Value = RadTextBox7.Text + "" |
| e.Command.Parameters("@DOLVALUE").Value = RadTextBox8.Text |
| e.Command.Parameters("@BOOKDATE").Value = Now() |
| e.Command.Parameters("@PROJECTNAME").Value = RadTextBox9.Text + "" |
| e.Command.Parameters("@NOTES2").Value = RadTextBox10.Text + "" |
| e.Command.Parameters("@PLANER").Value = Planner |
| e.Command.Parameters("@WHEREAT").Value = WhereAt |
| Button1.Visible = False |
| CompletedLabel.Visible = True |
| End Sub |
| Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load |
| RadTextBox1.Text = Int(Request.QueryString("dmd")) |
| RadTextBox3.Text = Int(Request.QueryString("line")) |
| RadTextBox5.Text = Request.QueryString("prod") + "" |
| RadTextBox4.Text = Int(Request.QueryString("qty")) |
| RadTextBox6.Text = Request.QueryString("net") |
| RadComboBox2.SelectedValue = Request.QueryString("plnr") |
| End Sub |
| End Class |
Does your code work if you set "Visible='false'" on the aspx page first? Yes I am also using Q3 dll's.
0
bradley baker
Top achievements
Rank 1
answered on 24 Nov 2009, 08:31 PM
Anything?
0
Accepted
Hello bradley baker,
Note that setting the Visibility=False to a server control does not render it at all on the page. So, even if you make some changes with the control on the server - getting a property (e.g. Text) will return the above error.
You can try hiding the control with style="display:none" in the combo's declaration.
Greetings,
Veselin Vasilev
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Note that setting the Visibility=False to a server control does not render it at all on the page. So, even if you make some changes with the control on the server - getting a property (e.g. Text) will return the above error.
You can try hiding the control with style="display:none" in the combo's declaration.
Greetings,
Veselin Vasilev
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.