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

Binding GridDropDownColumn To SQL Data source

3 Answers 127 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Amit
Top achievements
Rank 1
Amit asked on 08 Oct 2010, 01:11 PM
Hey,

I am not able to Populate dropdownlist with sql data source--aspx is

<telerik:GridDropDownColumn HeaderText="Items" UniqueName="column1" DataSourceID="SqlDataSource1"
                     ListTextField="ProductName" ListValueField="Pid" DataField="ProductName" >
                    </telerik:GridDropDownColumn>
Ans datasource is--
<asp:SqlDataSource ID="SqlDataSource1" runat="server" DataSourceMode="DataReader"
            ConnectionString="<%$ ConnectionStrings:ChalkHillConnectionString3 %>"
            SelectCommand="SELECT [ProductName] FROM [tblProducts] ORDER BY [Pid]"></asp:SqlDataSource>
I am trying to populate ddl from ProductName column of my tblProducts.
Does'nt seem to be workin'.I am getting this error--

'System.Data.Common.DataRecordInternal' does not contain a property with the name 'Pid'

Plz help..
Thanks
Amit

3 Answers, 1 is accepted

Sort by
0
Accepted
Pavlina
Telerik team
answered on 08 Oct 2010, 01:20 PM
Hi Amit,

You should set the ListValueField property to the name of the field in the lookup table that supplies the value for the field specified by the DataField property.

For more information on configuring GridDropDownColumn, see Customize/Configure GridDropDownColumn.

Greetings,

Pavlina
the Telerik team

 

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Amit
Top achievements
Rank 1
answered on 08 Oct 2010, 01:32 PM
hey pavlina,

My db table tblProducts has Columns--Pid(PK),ProductName,Rate and Quantity.
I want grid dropdown column to have all the Values under ProductName Field when in edit mode.So,I am setting its ListValueField to "Pid" and TextField tp ProductName.Now,could you plz elaborate a bit about the solution.

Thanks
Amit



0
Pavlina
Telerik team
answered on 13 Oct 2010, 11:03 AM
Hello Amit,

Try changing your code as shown below and let me know if it helps:
ASPX:
<telerik:GridDropDownColumn HeaderText="Items" UniqueName="column1" DataSourceID="SqlDataSource1"
                     ListTextField="ProductName" ListValueField="ProductName" DataField="ProductName" >  
                    </telerik:GridDropDownColumn>

Kind regards,
Pavlina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
Amit
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Amit
Top achievements
Rank 1
Share this question
or