Results 1 to 9 of 9

Thread: Gridview Header

  1. #1

    Thread Starter
    Frenzied Member EyeTalion's Avatar
    Join Date
    Jul 2000
    Location
    New York
    Posts
    1,075

    Gridview Header

    I tried changing the name of the header columns using the SELECT command, which works fine, but throws my UPDATE command off. Returns err msg: ORA-01036: illegal variable name/number


    Code:
     SelectCommand="SELECT SURPLUS_YR, DIV, SEQ_NO, SURPLUS_TYPE, DECAL_NO as Decal, FIELD_DESC, FIELD_MFGR, FIELD_SERIAL_NO, ITEM_CONDITION, SURPLUS_REASON FROM SPAR_DECAL_ITEM WHERE (SURPLUS_YR = :SURPLUS_YR) AND (SEQ_NO = :SEQ_NO) AND (DIV = :DIV)"
    Code:
    UpdateCommand="UPDATE SPAR_DECAL_ITEM SET FIELD_DESC = :FIELD_DESC, FIELD_MFGR = :FIELD_MFGR, FIELD_SERIAL_NO = :FIELD_SERIAL_NO, ITEM_CONDITION = :ITEM_CONDITION, SURPLUS_REASON = :SURPLUS_REASON WHERE (SURPLUS_YR = :SURPLUS_YR) AND (DIV = :DIV) AND (SEQ_NO = :SEQ_NO) AND (SURPLUS_TYPE = :SURPLUS_TYPE) AND (DECAL_NO = :DECAL_NO)">
    It's tough being an unhandled exception...

    ___________
    VB.NET 2008
    VB.NET 2010
    ORACLE 11g
    CRYSTAL 11

  2. #2
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Gridview Header

    Hey,

    You can edit the Header Column Name in the markup of the GridView, you don't have to do it in the Update Statement:

    http://msdn.microsoft.com/en-us/library/aa479342.aspx

    Use the HeaderText property.

    Gary

  3. #3

    Thread Starter
    Frenzied Member EyeTalion's Avatar
    Join Date
    Jul 2000
    Location
    New York
    Posts
    1,075

    Re: Gridview Header

    I configured my grid through the data source wizard and don't have any fields to select from to get to the HeaderText property?
    It's tough being an unhandled exception...

    ___________
    VB.NET 2008
    VB.NET 2010
    ORACLE 11g
    CRYSTAL 11

  4. #4
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Gridview Header

    Hey,

    Are you using AutoGenerateColumns?

    I assume you must be. In which case, you have two choices.

    1) Don't. And use BoundField Columns instead.
    2) Use the RowDataBound event for the GridView, determine if the row is of type header, and if it is, change the HeaderText for the column there.

    Gary

  5. #5

    Thread Starter
    Frenzied Member EyeTalion's Avatar
    Join Date
    Jul 2000
    Location
    New York
    Posts
    1,075

    Re: Gridview Header

    Something like this in the RowDataBound event?

    Code:
    gv.HeaderRow.Cells(1).Text = "New Header"
    It's tough being an unhandled exception...

    ___________
    VB.NET 2008
    VB.NET 2010
    ORACLE 11g
    CRYSTAL 11

  6. #6
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Gridview Header

    Hey,

    I don't have Visual Studio open to check, but that would seem like a logical approach.

    Gary

  7. #7

    Thread Starter
    Frenzied Member EyeTalion's Avatar
    Join Date
    Jul 2000
    Location
    New York
    Posts
    1,075

    Re: Gridview Header

    Using the RowDataBound event to change the header text, but getting this err msg: Object reference not set to an instance of an object





    Code:
    If e.Row.RowType = DataControlRowType.Header Then
                gv.HeaderRow.Cells(7).Text = "Header Text"
            End If
    It's tough being an unhandled exception...

    ___________
    VB.NET 2008
    VB.NET 2010
    ORACLE 11g
    CRYSTAL 11

  8. #8
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Gridview Header

    Hey,

    This would suggest that that Cell doesn't exist.

    Can you set a breakpoint on that line, and put this in the watch window:

    Code:
    gv.HeaderRow.Cells(7)
    Does it return Nothing? If so, are you sure that you have eight columns?

    Gary

  9. #9
    Hyperactive Member dnanetwork's Avatar
    Join Date
    Oct 2007
    Location
    Mumbai
    Posts
    349

    Re: Gridview Header

    if you are using Templates then..

    go to Templates..

    edit Templates..

    choose the columns..

    hit F4 and set the header Text..

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width