it's a lot of code, sorry about the size
1st vb.net , this works
Protected Sub InsertExtraHeader(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.GridViewRowEventArgs)
' Custom super header row
Dim gv As GridView = sender
Dim gvr0 As GridViewRow = New GridViewRow(0, 0,
DataControlRowType.Header, DataControlRowState.Insert)
Dim gvr As GridViewRow = New GridViewRow(0, 0,
DataControlRowType.Header, DataControlRowState.Insert)
Dim TD As TableCell = New TableCell
' add first new header spacer
TD.Text = HtmlTextWriter.SpaceChar
TD.ColumnSpan = 0
gvr.Cells.Add(TD)
'add ratine subheader
Dim td1 As TableCell = New TableCell
td1.Text = "RATING"
td1.ColumnSpan = 2
td1.HorizontalAlign = HorizontalAlign.Center
gvr.Cells.Add(td1)
' BP trend info
Dim td2 As TableCell = New TableCell
td2.Text = "TREND-BULLISH PERCENT"
td2.ColumnSpan = 3
td2.HorizontalAlign = HorizontalAlign.Center
gvr.Cells.Add(td2)
' 2 percent Short term
Dim td4 As TableCell = New TableCell
td4.Text = "SHORT TERM"
td4.ColumnSpan = 3
td4.HorizontalAlign = HorizontalAlign.Center
gvr.Cells.Add(td4)
' 4 Intermediate
Dim td5 As TableCell = New TableCell
td5.Text = "INTERMEDIATE TERM"
td5.ColumnSpan = 3
td5.HorizontalAlign = HorizontalAlign.Center
gvr.Cells.Add(td5)
' 6 long term
Dim td6 As TableCell = New TableCell
td6.Text = "LONG TERM"
td6.ColumnSpan = 2
td6.HorizontalAlign = HorizontalAlign.Center
gvr.Cells.Add(td6)
'10 week Momentum
Dim td3 As TableCell = New TableCell
td3.Text = "MOMENTUM 10 WEEK"
td3.HorizontalAlign = HorizontalAlign.Center
td3.ColumnSpan = 3
gvr.Cells.Add(td3)
'ok add filler fro rest
'Dim td99 As TableCell = New TableCell
'td99.Text = " "
'td99.ColumnSpan = 7
'gvr.Cells.Add(td99)
'add the new header row
gv.Controls(0).Controls.AddAt(0, gvr)
'insert the top header row
Dim td0 As TableCell = New TableCell
td0.Text = "SECTOR SNAP SHOT"
td0.HorizontalAlign = HorizontalAlign.Center
td0.Font.Size = FontUnit.Large
td0.ColumnSpan = 17
gvr0.Cells.Add(td0)
gv.Controls(0).Controls.AddAt(0, gvr0)
End Sub
C# code that overwrites and ingeneral is not even doing that correctly.
protected void insertExtraHeader(object sender, EventArgs e)
{
GridView gv = this.gvSSShot;
GridViewRow gvr0 = new GridViewRow(0, 0, DataControlRowType.Header,
DataControlRowState.Insert);
GridViewRow gvr = new GridViewRow(0, 0, DataControlRowType.Header,
DataControlRowState.Insert);
// insert the top header row
TableCell td0 = new TableCell();
td0.Text = "SECTOR SNAP SHOT";
td0.HorizontalAlign = HorizontalAlign.Center;
td0.Font.Size = FontUnit.Large;
td0.ColumnSpan = 17;
gvr0.Cells.Add(td0);
TableCell td = new TableCell();
td.Text = Html32TextWriter.SpaceChar.ToString();
td.ColumnSpan = 0;
gvr.Cells.Add(td);
TableCell td1 = new TableCell();
td1.Text = "RATING";
td1.ColumnSpan = 2;
td1.HorizontalAlign = HorizontalAlign.Center;
gvr.Cells.Add(td1);
// BP trend info
TableCell td2 = new TableCell();
td2.Text = "TREND-BULLISH PERCENT";
td2.ColumnSpan = 3;
td2.HorizontalAlign = HorizontalAlign.Center;
gvr.Cells.Add(td2);
//' 2 percent Short term
TableCell td4 = new TableCell();
td4.Text = "SHORT TERM";
td4.ColumnSpan = 3;
td4.HorizontalAlign = HorizontalAlign.Center;
gvr.Cells.Add(td4);
///' 4 Intermediate
TableCell td5 = new TableCell();
td5.Text = "INTERMEDIATE TERM";
td5.ColumnSpan = 3;
td5.HorizontalAlign = HorizontalAlign.Center;
gvr.Cells.Add(td5);
//' 6 long term
TableCell td6 = new TableCell();
td6.Text = "LONG TERM";
td6.ColumnSpan = 2;
td6.HorizontalAlign = HorizontalAlign.Center;
gvr.Cells.Add(td6);
//'10 week Momentum
TableCell td3 = new TableCell();
td3.Text = "MOMENTUM 10 WEEK";
td3.HorizontalAlign = HorizontalAlign.Center;
td3.ColumnSpan = 3;
gvr.Cells.Add(td3);
gv.Controls[0].Controls.AddAt(0, gvr);
gv.Controls[0].Controls.AddAt(0, gvr0);
}
--
(i''ll be asking a lot of these, but I find C# totally way cooler than vb
and there''s no go''n back!!!)
thanks (as always)
kes
David Anton said:
Post the C# and VB code. Even if it looks very close, there are subtle
differences between C# and VB (some can be surprising).
--
David Anton
http://www.tangiblesoftwaresolutions.com
Convert between VB, C#, C++, and Java
Instant C#
Instant VB
Instant C++
C++ to C# Converter
C++ to VB Converter
C++ to Java Converter
:
I have a sub in vb.net that adds extra headers to a gridview and it works
very well.
however, i tried to translate it to c# and i'm getting the header inserting
itself over the first datarows and inserting blank rows at the bottom.
i can post the code if necessary for the C# but it basicly mirrors the vb.net
--
(i''ll be asking a lot of these, but I find C# totally way cooler than vb
and there''s no go''n back!!!)
thanks (as always)
kes