gridview not displaying data.

Discussion in 'ASP .Net' started by Paul, Jun 18, 2008.

  1. Paul

    Paul Guest

    Hi I get the error (the data source for the gridview does not have any
    properties from which do generate columns)
    I am binding the data as follows, errors out on the databind line.
    The linksDataRepository is retrieved from a session variable and is working
    ok.


    linksDataRepository = (List<structRepo>)Session["linksDataRepository"];
    if (linksDataRepository != null)
    {
    gridview.DataSource = linksDataRepository;//
    gridview.DataBind();
    }
    and for the gridview I have
    <Columns>
    <asp:BoundField DataField="abspath" HeaderText="absolute path" />
    <asp:BoundField DataField="description" HeaderText="description" />
    <asp:BoundField DataField="icount" HeaderText="Count" />
    <asp:BoundField DataField="url" HeaderText="Url" />
    </Columns>
    as the structRepo is a structure with data abspath (string), description
    (string), icount (Integer), url (string). Any ideas?
    thanks.
    --
    Paul G
    Software engineer.
    Paul, Jun 18, 2008
    #1
    1. Advertising

  2. Paul

    Manish Guest

    Hi Paul,

    Please refer to the link below. this shows how you can bind the Grid to a
    List.

    http://forums.asp.net/p/1109165/1704585.aspx

    Regards,
    Manish
    www.ComponentOne.com

    "Paul" wrote:

    > Hi I get the error (the data source for the gridview does not have any
    > properties from which do generate columns)
    > I am binding the data as follows, errors out on the databind line.
    > The linksDataRepository is retrieved from a session variable and is working
    > ok.
    >
    >
    > linksDataRepository = (List<structRepo>)Session["linksDataRepository"];
    > if (linksDataRepository != null)
    > {
    > gridview.DataSource = linksDataRepository;//
    > gridview.DataBind();
    > }
    > and for the gridview I have
    > <Columns>
    > <asp:BoundField DataField="abspath" HeaderText="absolute path" />
    > <asp:BoundField DataField="description" HeaderText="description" />
    > <asp:BoundField DataField="icount" HeaderText="Count" />
    > <asp:BoundField DataField="url" HeaderText="Url" />
    > </Columns>
    > as the structRepo is a structure with data abspath (string), description
    > (string), icount (Integer), url (string). Any ideas?
    > thanks.
    > --
    > Paul G
    > Software engineer.
    Manish, Jun 19, 2008
    #2
    1. Advertising

  3. Paul

    Munna Guest

    Munna, Jun 19, 2008
    #3
  4. You can databind to properties, not to structure fields.

    --
    Eliyahu Goldin,
    Software Developer
    Microsoft MVP [ASP.NET]
    http://msmvps.com/blogs/egoldin
    http://usableasp.net


    "Paul" <> wrote in message
    news:D...
    > Hi I get the error (the data source for the gridview does not have any
    > properties from which do generate columns)
    > I am binding the data as follows, errors out on the databind line.
    > The linksDataRepository is retrieved from a session variable and is
    > working
    > ok.
    >
    >
    > linksDataRepository = (List<structRepo>)Session["linksDataRepository"];
    > if (linksDataRepository != null)
    > {
    > gridview.DataSource = linksDataRepository;//
    > gridview.DataBind();
    > }
    > and for the gridview I have
    > <Columns>
    > <asp:BoundField DataField="abspath" HeaderText="absolute path" />
    > <asp:BoundField DataField="description" HeaderText="description" />
    > <asp:BoundField DataField="icount" HeaderText="Count" />
    > <asp:BoundField DataField="url" HeaderText="Url" />
    > </Columns>
    > as the structRepo is a structure with data abspath (string), description
    > (string), icount (Integer), url (string). Any ideas?
    > thanks.
    > --
    > Paul G
    > Software engineer.
    Eliyahu Goldin, Jun 19, 2008
    #4
  5. Paul

    Paul Guest

    ok I will set up properties to retrieve the structure data in the list, thanks!
    --
    Paul G
    Software engineer.


    "Eliyahu Goldin" wrote:

    > You can databind to properties, not to structure fields.
    >
    > --
    > Eliyahu Goldin,
    > Software Developer
    > Microsoft MVP [ASP.NET]
    > http://msmvps.com/blogs/egoldin
    > http://usableasp.net
    >
    >
    > "Paul" <> wrote in message
    > news:D...
    > > Hi I get the error (the data source for the gridview does not have any
    > > properties from which do generate columns)
    > > I am binding the data as follows, errors out on the databind line.
    > > The linksDataRepository is retrieved from a session variable and is
    > > working
    > > ok.
    > >
    > >
    > > linksDataRepository = (List<structRepo>)Session["linksDataRepository"];
    > > if (linksDataRepository != null)
    > > {
    > > gridview.DataSource = linksDataRepository;//
    > > gridview.DataBind();
    > > }
    > > and for the gridview I have
    > > <Columns>
    > > <asp:BoundField DataField="abspath" HeaderText="absolute path" />
    > > <asp:BoundField DataField="description" HeaderText="description" />
    > > <asp:BoundField DataField="icount" HeaderText="Count" />
    > > <asp:BoundField DataField="url" HeaderText="Url" />
    > > </Columns>
    > > as the structRepo is a structure with data abspath (string), description
    > > (string), icount (Integer), url (string). Any ideas?
    > > thanks.
    > > --
    > > Paul G
    > > Software engineer.

    >
    >
    >
    Paul, Jun 19, 2008
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. .Net Sports

    datagrid not displaying data table data

    .Net Sports, Aug 30, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    2,763
    .Net Sports
    Aug 31, 2005
  2. Greg Lyles
    Replies:
    8
    Views:
    556
    Billy Biro
    Dec 4, 2006
  3. David C

    displaying data for GridView

    David C, Jul 24, 2007, in forum: ASP .Net
    Replies:
    2
    Views:
    381
    =?Utf-8?B?U2VyZ2V5IFBvYmVyZXpvdnNraXk=?=
    Jul 24, 2007
  4. Cirene
    Replies:
    1
    Views:
    272
    Cirene
    Nov 15, 2007
  5. Dave
    Replies:
    1
    Views:
    779
    Munna
    Jul 12, 2008
Loading...

Share This Page