DataGrid & Datalist

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Yogesh Sharma
    New Member
    • Mar 2008
    • 40

    DataGrid & Datalist

    I was asked in one of the interview--
    Where We r use datagrid & Where we r use dalalist in our Application?

    I have fetched the data using the dataGrid, But I do not kno abt the DataList.
    DataList is not even in the Toolbox.

    So pls reply to the answer asap & also send the code how to retrieve the data using DataList.
  • balabaster
    Recognized Expert Contributor
    • Mar 2007
    • 798

    #2
    Originally posted by Yogesh Sharma
    I was asked in one of the interview--
    Where We r use datagrid & Where we r use dalalist in our Application?

    I have fetched the data using the dataGrid, But I do not kno abt the DataList.
    DataList is not even in the Toolbox.

    So pls reply to the answer asap & also send the code how to retrieve the data using DataList.
    What version of Visual Studio are they using and what version are you using?

    They'll be using DataGrid and DataList in their .NET 1.0/1.1 Web Applications - if they're using the DataGrid in their 2.0 applications, they should think about upgrading.

    I have 2008 and in my web application toolbox I have GridView and DataList (under the Data section)...I know that GridView was introduced in the 2003 version and prior to that they used DataGrid - it has of course been deprecated and replaced with GridView now which is basically DataGrid on steroids.

    I've gotta admit, I've never used DataList, so I can't give any extensive details about it. At first glance it looks to be similar to GridView except that it's single column.

    Comment

    • Yogesh Sharma
      New Member
      • Mar 2008
      • 40

      #3
      I m using the version 2005, & in 2005, there is no datalist under the data Tab.
      Even u dont know how to fetch the records from the databse into the Datalist.

      When to use datalist & dataGrid? can u asnwer dat?

      Comment

      • balabaster
        Recognized Expert Contributor
        • Mar 2007
        • 798

        #4
        If you need a 2 dimensional grid - such as a spreadsheet style display, use a DataGrid, if you need single dimensional data such as a columnnar data...a list.

        [Code=html] <asp:SqlDataSou rce
        ID="SqlDataSour ce1"
        runat="server"
        ConnectionStrin g="<%$ ConnectionStrin gs:MyConnection String%>"
        SelectCommand=" SELECT Location_Key, Location_Name FROM [Location]" />


        <asp:DataList
        ID="DataList1"
        runat="server"
        DataSourceID="S qlDataSource1"
        DataKeyField="L ocation_Key" >
        <ItemTemplate>L ocation_Key:
        <asp:Label
        ID="Location_PK eyLabel"
        runat="server"
        Text='<%# Eval("Location_ PKey") %>' /><br />
        Location_Name:
        <asp:Label
        ID="Location_Na meLabel"
        runat="server"
        Text='<%# Eval("Location_ Name") %>' />
        </ItemTemplate>
        </asp:DataList>
        [/Code]

        Comment

        Working...