-
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)">
-
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
-
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?
-
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
-
Re: Gridview Header
Something like this in the RowDataBound event?
Code:
gv.HeaderRow.Cells(1).Text = "New Header"
-
Re: Gridview Header
Hey,
I don't have Visual Studio open to check, but that would seem like a logical approach.
Gary
-
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
-
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
-
Re: Gridview Header
if you are using Templates then..
go to Templates..
edit Templates..
choose the columns..
hit F4 and set the header Text..