+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Using the GridView control

Using the GridView control

13 posts, 0 answered
  1. aster
    aster avatar
    12 posts
    Registered:
    08 Dec 2009
    15 Jan 2010
    Link to this post
    I would like to display a company phone list using the grid view control on a page. When I drag the grid view control from the "Data" section, it shows me dummy data.  I know I can go into the "Edit" section and populate the "DataSourceID" with a value to populate data, but how do I hook it up to the data I would like to point it to.Say I have a SQL table, where would I put the plumbing in place for this grid view to display my SQL table?

    Thanks!
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    17 Jan 2010
    Link to this post
    Hi aster,

    You can use SqlDataSource control

    SelectCommand property - set your select command
    ConnectionString - set connectionString to your database.

    You can gather more information at Selecting Data Using the SqlDataSource Control

    Best wishes,
    Ivan Dimitrov
    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.
  3. Gene
    Gene avatar
    2 posts
    Registered:
    28 Dec 2007
    09 Feb 2010
    Link to this post
    Ivan,

    I have the same question.  If you drag a gridview control to a content area of your page, how do you wire up the SqlDataSource?  I don't see that in the sitefinity controls.

    Thanks,
    Gene.
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    10 Feb 2010
    Link to this post
    Hi Gene,

    Drop GridView and your data source control in the same naming container. Then set the DataSourceID property of the GridView with the ID of SqlDataSource control.

    All the best,
    Ivan Dimitrov
    the Telerik team

    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Follow the status of features or bugs in PITS and vote for them to affect their priority.
  5. Scott Poole
    Scott Poole avatar
    6 posts
    Registered:
    14 Apr 2010
    26 May 2010
    Link to this post
    Hello Ivan,
      I don't think you understand the question. Example:

    I have a page that I want to place a gridview on and display information from a SQL database. I look in "Add Control" and I see the gridview control, so I can drag and drop that one no problem. However, I do not see a SQLDataSource control to drag onto the page. Where is this mythical control?

    Thanks,
      Andy
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    26 May 2010
    Link to this post
    Hi Andrew Casey,

    You can register the SqlDataSource control in your toolbox section.

    web.config

    <toolboxControls
        <clear />
    <add name="SqlDataSource" section="Data" type="System.Web.UI.WebControls.SqlDataSource, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
     
     
    ....
         ...



    Kind regards,
    Ivan Dimitrov
    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.
  7. Scott Poole
    Scott Poole avatar
    6 posts
    Registered:
    14 Apr 2010
    30 Jul 2010
    Link to this post
    Hello,
      I tried to place the SQLDataSource control onto the page and then place the gridview control on the page.
    When I try to preview the page, I just get an error that the page cannot be displayed. If I take the gridview off of the page, it displays fine. It displays nothing, but at least the page comes up. So, I have two questions:

    1) I have a connect string in my web.config file. Can I just use the name of the connection string in the SqlDataSource control or do I have to put in the entire connection string?

    2) Other than supplying the ID of the SqlDataSource control in the gridview, is there anything else I need to supply?

    Thanks,
      Andrew Casey
  8. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    30 Jul 2010
    Link to this post
    Hi Andrew Casey,

    SqlDataSource is standard ASP.NET control that comes from .NET Framework. You can take a look at the control overview and its properties which are well documented as MSDN. You can gather more information for the GridView here.

    Greetings,
    Ivan Dimitrov
    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
  9. Scott Poole
    Scott Poole avatar
    6 posts
    Registered:
    14 Apr 2010
    30 Jul 2010
    Link to this post
    Hello Ivan,
      So, if that's the case, then I can use the follwing line for the connection string?

    <%

     

    $ ConnectionStrings:cupsecure %>

     



    Thanks,
      Andrew Casey
  10. Scott Poole
    Scott Poole avatar
    6 posts
    Registered:
    14 Apr 2010
    30 Jul 2010
    Link to this post

    Hello Ivan,
      I am also getting a strange message when I drag a control onto a page or delete it. The message below pops on the screen and then it goes back to the editor.

    No controls have been added to this container. Dra

    Any ideas? Related to the issue at hand?

    Thanks,
      Andrew Casey
  11. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    02 Aug 2010
    Link to this post
    Hi Andrew Casey,

    Could you please provide the updated markup and source code of your control? We would take a look at it and see what might be causing the error.

    Sincerely yours,
    Radoslav Georgiev
    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
  12. Scott Poole
    Scott Poole avatar
    6 posts
    Registered:
    14 Apr 2010
    02 Aug 2010
    Link to this post
    Hello,
      I was using the controls that come with Sitefinity, like the gridview control and the sqldatasource control.

    Andy Casey
  13. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    03 Aug 2010
    Link to this post
    Hello Andrew Casey,

    Thank you for getting back to me.

    If you are using those controls withing the page editor directly you should first drop the data source control and then add Grid view. The recommended approach however is to wrap those control in .ascx files and then upload them to the Sitefinity toolbox.

    Sincerely yours,
    Radoslav Georgiev
    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
Register for webinar
13 posts, 0 answered