Accessing data grid column

Discussion in 'ASP .Net Datagrid Control' started by John, Aug 27, 2006.

  1. John

    John Guest

    Hi

    I have a hidden (visible=false) column on a gridview bound to a sql server
    table. I am trying to access the field as;

    For Each row As GridViewRow In grdEvents.Rows
    If row.RowType = DataControlRowType.DataRow Then
    bf = CType(row.Cells(row.Cells.Count - 1).FindControl("event id"),
    BoundField)
    End if
    Next

    but I get the 'System.Web.UI.Control' cannot be converted to
    System.Web.UI.WebControls.BoundField' error. When I try to access it using
    row.Cells(12).Text then it returns a blank value.

    How can I access the relevant gridview column?

    Thanks

    Regards
     
    John, Aug 27, 2006
    #1
    1. Advertising

  2. John

    John Guest

    Hi

    I have used the 'Configure Data Source' to bind the gridview. Where would I
    find the databind method in this case?

    Thanks

    Regards

    "Mark Rae" <> wrote in message
    news:e$...
    > "John" <> wrote in message
    > news:...
    >
    >
    >> How can I access the relevant gridview column?

    >
    > Set the column Visible = True immediately before calling the GridView's
    > DataBind method, then set it Visible = False immediately afterwards...
    >
     
    John, Aug 27, 2006
    #2
    1. Advertising

  3. John

    KJ Guest

    Hello John,

    I am guessing you used an ObjectDataSource control to act as a
    datasource for the gridview? Check the following:

    The DataSourceID property of the gridview is set to that of the
    objectdatasource.
    WHen you call DataBind() on the gridview, the SelectMethod of the
    objectdatasource is implicitly called.

    John wrote:
    > Hi
    >
    > I have used the 'Configure Data Source' to bind the gridview. Where would I
    > find the databind method in this case?
    >
    > Thanks
    >
    > Regards
    >
    > "Mark Rae" <> wrote in message
    > news:e$...
    > > "John" <> wrote in message
    > > news:...
    > >
    > >
    > >> How can I access the relevant gridview column?

    > >
    > > Set the column Visible = True immediately before calling the GridView's
    > > DataBind method, then set it Visible = False immediately afterwards...
    > >
     
    KJ, Aug 28, 2006
    #3
    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. Balu

    Data Grid Column Visibility

    Balu, Jan 3, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    516
  2. Balu
    Replies:
    4
    Views:
    14,935
    =?Utf-8?B?Tm90SGVscGZ1bA==?=
    Jan 12, 2006
  3. C Newby
    Replies:
    7
    Views:
    574
    C Newby
    Apr 2, 2004
  4. carlos perez
    Replies:
    0
    Views:
    417
    carlos perez
    Jun 8, 2004
  5. John

    Accessing data grid column

    John, Aug 27, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    2,987
Loading...

Share This Page