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

[Solved] Dropdow in the grid

1 Answer 85 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Yma
Top achievements
Rank 1
Yma asked on 10 Oct 2009, 05:03 PM
I am using RadControls-grdInsertUpdateDeleteAtDatabaseLevel sample program in http://demos.telerik.com/aspnet-ajax/grid/examples/dataediting/alleditablecolumns/defaultcs.aspx
 
I want to show a grid field as a drop down from another datasource. But I am getting an error when I am trying to update it. I have given here what I have done currently. I am getting this error when I add the drop down. Can you tell me how can I add it to the .cs code to get the selected ID.
 
.ASPX
 
<telerik:GridBoundColumn DataField="Password" HeaderText="Password" UniqueName="Password"> </telerik:GridBoundColumn>
 <telerik:GridDropDownColumn DataField="CompanyID" DataSourceID="SqlDataSource2"HeaderText="CompanyID" ListTextField="CompanyName" ListValueField="CompanyID" UniqueName="CategoryID" ColumnEditorID="GridDropDownColumnEditor1"></telerik:GridDropDownColumn>
 
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:TestDataConnectionString2 %>" SelectCommand="SELECT [CompanyID], [CompanyName], [CompanyCode], [AddressLine01], [AddressLine02], [AddressLine03], [AddressLine04], [PostCode], [Country], [Telephone], [Fax], [Web], [default] FROM [tbl_LU_Companies]"></asp:SqlDataSource>

.CS
string Password = (editedItem["Password"].Controls[0] as TextBox).Text;
string CompanyID = (editedItem["CompanyID"].Controls[0] as TextBox).Text;

How can I get the Company ID. Can you help me please.
 
Thank you,

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 12 Oct 2009, 07:07 AM
Hello,

You could typecast the dropdown control to RadComboBox in order to get the selected value. Give a try with this code.
.cs
       string CompanyID = (editedItem["CompanyName1"].Controls[0] as RadComboBox).Text;

I hope this help,
Shinu.
Tags
Grid
Asked by
Yma
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or