Datasource for RadGrid control

4 posts, 0 answers
  1. MSQ
    MSQ avatar
    3 posts
    Member since:
    Jan 2013

    Posted 27 Jun 2014 Link to this post

    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>
  2. Kostadin
    Admin
    Kostadin avatar
    1708 posts

    Posted 02 Jul 2014 Link to this post

    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.

     
  3. DevCraft banner
  4. Raza
    Raza avatar
    2 posts
    Member since:
    Jul 2014

    Posted 21 Aug 2014 in reply to MSQ Link to this post

    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>
  5. Raza
    Raza avatar
    2 posts
    Member since:
    Jul 2014

    Posted 21 Aug 2014 in reply to Raza Link to this post

    Mo,

    Mistake:

    I meant here not in the closing tag.............  <MasterTableView Width="100%" DataSourceID=SqlDataSource1 DataKeyNames=AccoutnID>
Back to Top