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

Datasource for RadGrid control

3 Answers 42 Views
Data Access Free Edition
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
MSQ
Top achievements
Rank 1
MSQ asked on 27 Jun 2014, 10:23 PM
I have the following code in asp.net; how do I find the datasource for this control?

<telerik:RadGrid ID="Account" runat="server" Width="100%" AutoGenerateColumns="False"
AllowSorting="True" GridLines="None" BackColor="Linen" Skin="Outlook" Height="100%" >
<MasterTableView Width="100%">
<Columns>
<telerik:GridBoundColumn HeaderText="Type" UniqueName="TYP_colType" DataField="Type" >
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
<HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" />
</telerik:GridBoundColumn>
</Columns>
</MasterTableView>

3 Answers, 1 is accepted

Sort by
0
Kostadin
Telerik team
answered on 02 Jul 2014, 11:47 AM
Hello Mo,

I am not completely sure what exactly you are meaning by "how do I find the datasource for this control?". Could you please elaborate a little bit more on your request? Generally you are applying a datasource to the RadGrid controls, so you already know it and can access its data.

Regards,
Kostadin
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Raza
Top achievements
Rank 1
answered on 21 Aug 2014, 05:11 PM
Mate, you don't have a DataSource in the RadGrid control so you can't find it!  You got to add the DataSource to the grid from the toolbox or in HTML, either drag a SQLDataSource, OpenAccessDataSOurce or an OpenAccessLinqdataSource control in design view. 

If you did, you would be looking for the DataSourceID property inside both the <telerik:RadGrid> and <MasterTableView> HTML tags so in 2 places. 

e.g. see in bold below your appended markup....note put your PrimaryKey (e.g. AccountID) in the DataKeyNames property.

<telerik:RadGrid ID="Account" runat="server" Width="100%" AutoGenerateColumns="False" DataSourceID=SqlDataSource1
AllowSorting="True" GridLines="None" BackColor="Linen" Skin="Outlook" Height="100%" >
<MasterTableView Width="100%" >
<Columns>
<telerik:GridBoundColumn HeaderText="Type" UniqueName="TYP_colType" DataField="Type" >
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
<HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" />
</telerik:GridBoundColumn>
</Columns>
</MasterTableView DataSourceID=SqlDataSource1 DataKeyNames=AccountID>
0
Raza
Top achievements
Rank 1
answered on 21 Aug 2014, 05:15 PM
Mo,

Mistake:

I meant here not in the closing tag.............  <MasterTableView Width="100%" DataSourceID=SqlDataSource1 DataKeyNames=AccoutnID>
Tags
Data Access Free Edition
Asked by
MSQ
Top achievements
Rank 1
Answers by
Kostadin
Telerik team
Raza
Top achievements
Rank 1
Share this question
or