473,765 Members | 2,010 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

vb vs cs gridview header question

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
Sep 11 '07 #1
5 1971
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
"WebBuilder 451" wrote:
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
Sep 12 '07 #2
it's a lot of code, sorry about the size
1st vb.net , this works
Protected Sub InsertExtraHead er(ByVal sender As Object, ByVal e As
System.Web.UI.W ebControls.Grid ViewRowEventArg s)
' Custom super header row
Dim gv As GridView = sender
Dim gvr0 As GridViewRow = New GridViewRow(0, 0,
DataControlRowT ype.Header, DataControlRowS tate.Insert)
Dim gvr As GridViewRow = New GridViewRow(0, 0,
DataControlRowT ype.Header, DataControlRowS tate.Insert)
Dim TD As TableCell = New TableCell
' add first new header spacer
TD.Text = HtmlTextWriter. SpaceChar
TD.ColumnSpan = 0
gvr.Cells.Add(T D)

'add ratine subheader
Dim td1 As TableCell = New TableCell
td1.Text = "RATING"
td1.ColumnSpan = 2
td1.HorizontalA lign = HorizontalAlign .Center
gvr.Cells.Add(t d1)

' BP trend info
Dim td2 As TableCell = New TableCell
td2.Text = "TREND-BULLISH PERCENT"
td2.ColumnSpan = 3
td2.HorizontalA lign = HorizontalAlign .Center
gvr.Cells.Add(t d2)
' 2 percent Short term
Dim td4 As TableCell = New TableCell
td4.Text = "SHORT TERM"
td4.ColumnSpan = 3
td4.HorizontalA lign = HorizontalAlign .Center
gvr.Cells.Add(t d4)

' 4 Intermediate
Dim td5 As TableCell = New TableCell
td5.Text = "INTERMEDIA TE TERM"
td5.ColumnSpan = 3
td5.HorizontalA lign = HorizontalAlign .Center
gvr.Cells.Add(t d5)

' 6 long term
Dim td6 As TableCell = New TableCell
td6.Text = "LONG TERM"
td6.ColumnSpan = 2
td6.HorizontalA lign = HorizontalAlign .Center
gvr.Cells.Add(t d6)

'10 week Momentum
Dim td3 As TableCell = New TableCell
td3.Text = "MOMENTUM 10 WEEK"
td3.HorizontalA lign = HorizontalAlign .Center
td3.ColumnSpan = 3
gvr.Cells.Add(t d3)

'ok add filler fro rest
'Dim td99 As TableCell = New TableCell
'td99.Text = " "
'td99.ColumnSpa n = 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.HorizontalA lign = 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 insertExtraHead er(object sender, EventArgs e)
{
GridView gv = this.gvSSShot;
GridViewRow gvr0 = new GridViewRow(0, 0, DataControlRowT ype.Header,
DataControlRowS tate.Insert);
GridViewRow gvr = new GridViewRow(0, 0, DataControlRowT ype.Header,
DataControlRowS tate.Insert);

// insert the top header row
TableCell td0 = new TableCell();
td0.Text = "SECTOR SNAP SHOT";
td0.HorizontalA lign = HorizontalAlign .Center;
td0.Font.Size = FontUnit.Large;
td0.ColumnSpan = 17;
gvr0.Cells.Add( td0);
TableCell td = new TableCell();
td.Text = Html32TextWrite r.SpaceChar.ToS tring();
td.ColumnSpan = 0;
gvr.Cells.Add(t d);

TableCell td1 = new TableCell();
td1.Text = "RATING";
td1.ColumnSpan = 2;
td1.HorizontalA lign = HorizontalAlign .Center;
gvr.Cells.Add(t d1);

// BP trend info
TableCell td2 = new TableCell();
td2.Text = "TREND-BULLISH PERCENT";
td2.ColumnSpan = 3;
td2.HorizontalA lign = HorizontalAlign .Center;
gvr.Cells.Add(t d2);
//' 2 percent Short term
TableCell td4 = new TableCell();
td4.Text = "SHORT TERM";
td4.ColumnSpan = 3;
td4.HorizontalA lign = HorizontalAlign .Center;
gvr.Cells.Add(t d4);

///' 4 Intermediate
TableCell td5 = new TableCell();
td5.Text = "INTERMEDIA TE TERM";
td5.ColumnSpan = 3;
td5.HorizontalA lign = HorizontalAlign .Center;
gvr.Cells.Add(t d5);

//' 6 long term
TableCell td6 = new TableCell();
td6.Text = "LONG TERM";
td6.ColumnSpan = 2;
td6.HorizontalA lign = HorizontalAlign .Center;
gvr.Cells.Add(t d6);

//'10 week Momentum
TableCell td3 = new TableCell();
td3.Text = "MOMENTUM 10 WEEK";
td3.HorizontalA lign = HorizontalAlign .Center;
td3.ColumnSpan = 3;
gvr.Cells.Add(t d3);

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" wrote:
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
"WebBuilder 451" wrote:
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
Sep 12 '07 #3
Here is an actual automated conversion (from Instant C#).
Although it's a good learning situation to convert by hand, I think you will
run into a lot of problems doing this - right off the top, the type of your
'e' parameter was wrong.
protected void InsertExtraHead er(object sender,
System.Web.UI.W ebControls.Grid ViewRowEventArg s e)
{
// Custom super header row
GridView gv = (GridView)sende r;
GridViewRow gvr0 = new GridViewRow(0, 0, DataControlRowT ype.Header,
DataControlRowS tate.Insert);
GridViewRow gvr = new GridViewRow(0, 0, DataControlRowT ype.Header,
DataControlRowS tate.Insert);
TableCell TD = new TableCell();
// add first new header spacer
TD.Text = HtmlTextWriter. SpaceChar;
TD.ColumnSpan = 0;
gvr.Cells.Add(T D);

//add ratine subheader
TableCell td1 = new TableCell();
td1.Text = "RATING";
td1.ColumnSpan = 2;
td1.HorizontalA lign = HorizontalAlign .Center;
gvr.Cells.Add(t d1);

// BP trend info
TableCell td2 = new TableCell();
td2.Text = "TREND-BULLISH PERCENT";
td2.ColumnSpan = 3;
td2.HorizontalA lign = HorizontalAlign .Center;
gvr.Cells.Add(t d2);
// 2 percent Short term
TableCell td4 = new TableCell();
td4.Text = "SHORT TERM";
td4.ColumnSpan = 3;
td4.HorizontalA lign = HorizontalAlign .Center;
gvr.Cells.Add(t d4);

// 4 Intermediate
TableCell td5 = new TableCell();
td5.Text = "INTERMEDIA TE TERM";
td5.ColumnSpan = 3;
td5.HorizontalA lign = HorizontalAlign .Center;
gvr.Cells.Add(t d5);

// 6 long term
TableCell td6 = new TableCell();
td6.Text = "LONG TERM";
td6.ColumnSpan = 2;
td6.HorizontalA lign = HorizontalAlign .Center;
gvr.Cells.Add(t d6);

//10 week Momentum
TableCell td3 = new TableCell();
td3.Text = "MOMENTUM 10 WEEK";
td3.HorizontalA lign = HorizontalAlign .Center;
td3.ColumnSpan = 3;
gvr.Cells.Add(t d3);

//ok add filler fro rest
//Dim td99 As TableCell = New TableCell
//td99.Text = " "
//td99.ColumnSpan = 7
//gvr.Cells.Add(t d99)
//add the new header row
gv.Controls[0].Controls.AddAt (0, gvr);

//insert the top header row
TableCell td0 = new TableCell();
td0.Text = "SECTOR SNAP SHOT";
td0.HorizontalA lign = HorizontalAlign .Center;
td0.Font.Size = FontUnit.Large;
td0.ColumnSpan = 17;
gvr0.Cells.Add( td0);
gv.Controls[0].Controls.AddAt (0, gvr0);
}

--
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
"WebBuilder 451" wrote:
it's a lot of code, sorry about the size
1st vb.net , this works
Protected Sub InsertExtraHead er(ByVal sender As Object, ByVal e As
System.Web.UI.W ebControls.Grid ViewRowEventArg s)
' Custom super header row
Dim gv As GridView = sender
Dim gvr0 As GridViewRow = New GridViewRow(0, 0,
DataControlRowT ype.Header, DataControlRowS tate.Insert)
Dim gvr As GridViewRow = New GridViewRow(0, 0,
DataControlRowT ype.Header, DataControlRowS tate.Insert)
Dim TD As TableCell = New TableCell
' add first new header spacer
TD.Text = HtmlTextWriter. SpaceChar
TD.ColumnSpan = 0
gvr.Cells.Add(T D)

'add ratine subheader
Dim td1 As TableCell = New TableCell
td1.Text = "RATING"
td1.ColumnSpan = 2
td1.HorizontalA lign = HorizontalAlign .Center
gvr.Cells.Add(t d1)

' BP trend info
Dim td2 As TableCell = New TableCell
td2.Text = "TREND-BULLISH PERCENT"
td2.ColumnSpan = 3
td2.HorizontalA lign = HorizontalAlign .Center
gvr.Cells.Add(t d2)
' 2 percent Short term
Dim td4 As TableCell = New TableCell
td4.Text = "SHORT TERM"
td4.ColumnSpan = 3
td4.HorizontalA lign = HorizontalAlign .Center
gvr.Cells.Add(t d4)

' 4 Intermediate
Dim td5 As TableCell = New TableCell
td5.Text = "INTERMEDIA TE TERM"
td5.ColumnSpan = 3
td5.HorizontalA lign = HorizontalAlign .Center
gvr.Cells.Add(t d5)

' 6 long term
Dim td6 As TableCell = New TableCell
td6.Text = "LONG TERM"
td6.ColumnSpan = 2
td6.HorizontalA lign = HorizontalAlign .Center
gvr.Cells.Add(t d6)

'10 week Momentum
Dim td3 As TableCell = New TableCell
td3.Text = "MOMENTUM 10 WEEK"
td3.HorizontalA lign = HorizontalAlign .Center
td3.ColumnSpan = 3
gvr.Cells.Add(t d3)

'ok add filler fro rest
'Dim td99 As TableCell = New TableCell
'td99.Text = " "
'td99.ColumnSpa n = 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.HorizontalA lign = 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 insertExtraHead er(object sender, EventArgs e)
{
GridView gv = this.gvSSShot;
GridViewRow gvr0 = new GridViewRow(0, 0, DataControlRowT ype.Header,
DataControlRowS tate.Insert);
GridViewRow gvr = new GridViewRow(0, 0, DataControlRowT ype.Header,
DataControlRowS tate.Insert);

// insert the top header row
TableCell td0 = new TableCell();
td0.Text = "SECTOR SNAP SHOT";
td0.HorizontalA lign = HorizontalAlign .Center;
td0.Font.Size = FontUnit.Large;
td0.ColumnSpan = 17;
gvr0.Cells.Add( td0);
TableCell td = new TableCell();
td.Text = Html32TextWrite r.SpaceChar.ToS tring();
td.ColumnSpan = 0;
gvr.Cells.Add(t d);

TableCell td1 = new TableCell();
td1.Text = "RATING";
td1.ColumnSpan = 2;
td1.HorizontalA lign = HorizontalAlign .Center;
gvr.Cells.Add(t d1);

// BP trend info
TableCell td2 = new TableCell();
td2.Text = "TREND-BULLISH PERCENT";
td2.ColumnSpan = 3;
td2.HorizontalA lign = HorizontalAlign .Center;
gvr.Cells.Add(t d2);
//' 2 percent Short term
TableCell td4 = new TableCell();
td4.Text = "SHORT TERM";
td4.ColumnSpan = 3;
td4.HorizontalA lign = HorizontalAlign .Center;
gvr.Cells.Add(t d4);

///' 4 Intermediate
TableCell td5 = new TableCell();
td5.Text = "INTERMEDIA TE TERM";
td5.ColumnSpan = 3;
td5.HorizontalA lign = HorizontalAlign .Center;
gvr.Cells.Add(t d5);

//' 6 long term
TableCell td6 = new TableCell();
td6.Text = "LONG TERM";
td6.ColumnSpan = 2;
td6.HorizontalA lign = HorizontalAlign .Center;
gvr.Cells.Add(t d6);

//'10 week Momentum
TableCell td3 = new TableCell();
td3.Text = "MOMENTUM 10 WEEK";
td3.HorizontalA lign = HorizontalAlign .Center;
td3.ColumnSpan = 3;
gvr.Cells.Add(t d3);

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" wrote:
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
"WebBuilder 451" wrote:
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
Sep 12 '07 #4
thanks for responding
same thing happened. now here is how it is called
from the row created:
protected void gvSSShot_RowCre ated(object sender, GridViewRowEven tArgs e)
{
if (e.Row.RowType == DataControlRowT ype.Header)
this.InsertExtr aHeader(sender, e);
}
In vb i'm doing it from the row databound, but for some reason this is not
giving me any results

also the tool you used is better than most i've seen.

--
(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" wrote:
Here is an actual automated conversion (from Instant C#).
Although it's a good learning situation to convert by hand, I think you will
run into a lot of problems doing this - right off the top, the type of your
'e' parameter was wrong.
protected void InsertExtraHead er(object sender,
System.Web.UI.W ebControls.Grid ViewRowEventArg s e)
{
// Custom super header row
GridView gv = (GridView)sende r;
GridViewRow gvr0 = new GridViewRow(0, 0, DataControlRowT ype.Header,
DataControlRowS tate.Insert);
GridViewRow gvr = new GridViewRow(0, 0, DataControlRowT ype.Header,
DataControlRowS tate.Insert);
TableCell TD = new TableCell();
// add first new header spacer
TD.Text = HtmlTextWriter. SpaceChar;
TD.ColumnSpan = 0;
gvr.Cells.Add(T D);

//add ratine subheader
TableCell td1 = new TableCell();
td1.Text = "RATING";
td1.ColumnSpan = 2;
td1.HorizontalA lign = HorizontalAlign .Center;
gvr.Cells.Add(t d1);

// BP trend info
TableCell td2 = new TableCell();
td2.Text = "TREND-BULLISH PERCENT";
td2.ColumnSpan = 3;
td2.HorizontalA lign = HorizontalAlign .Center;
gvr.Cells.Add(t d2);
// 2 percent Short term
TableCell td4 = new TableCell();
td4.Text = "SHORT TERM";
td4.ColumnSpan = 3;
td4.HorizontalA lign = HorizontalAlign .Center;
gvr.Cells.Add(t d4);

// 4 Intermediate
TableCell td5 = new TableCell();
td5.Text = "INTERMEDIA TE TERM";
td5.ColumnSpan = 3;
td5.HorizontalA lign = HorizontalAlign .Center;
gvr.Cells.Add(t d5);

// 6 long term
TableCell td6 = new TableCell();
td6.Text = "LONG TERM";
td6.ColumnSpan = 2;
td6.HorizontalA lign = HorizontalAlign .Center;
gvr.Cells.Add(t d6);

//10 week Momentum
TableCell td3 = new TableCell();
td3.Text = "MOMENTUM 10 WEEK";
td3.HorizontalA lign = HorizontalAlign .Center;
td3.ColumnSpan = 3;
gvr.Cells.Add(t d3);

//ok add filler fro rest
//Dim td99 As TableCell = New TableCell
//td99.Text = " "
//td99.ColumnSpan = 7
//gvr.Cells.Add(t d99)
//add the new header row
gv.Controls[0].Controls.AddAt (0, gvr);

//insert the top header row
TableCell td0 = new TableCell();
td0.Text = "SECTOR SNAP SHOT";
td0.HorizontalA lign = HorizontalAlign .Center;
td0.Font.Size = FontUnit.Large;
td0.ColumnSpan = 17;
gvr0.Cells.Add( td0);
gv.Controls[0].Controls.AddAt (0, gvr0);
}

--
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
"WebBuilder 451" wrote:
it's a lot of code, sorry about the size
1st vb.net , this works
Protected Sub InsertExtraHead er(ByVal sender As Object, ByVal e As
System.Web.UI.W ebControls.Grid ViewRowEventArg s)
' Custom super header row
Dim gv As GridView = sender
Dim gvr0 As GridViewRow = New GridViewRow(0, 0,
DataControlRowT ype.Header, DataControlRowS tate.Insert)
Dim gvr As GridViewRow = New GridViewRow(0, 0,
DataControlRowT ype.Header, DataControlRowS tate.Insert)
Dim TD As TableCell = New TableCell
' add first new header spacer
TD.Text = HtmlTextWriter. SpaceChar
TD.ColumnSpan = 0
gvr.Cells.Add(T D)

'add ratine subheader
Dim td1 As TableCell = New TableCell
td1.Text = "RATING"
td1.ColumnSpan = 2
td1.HorizontalA lign = HorizontalAlign .Center
gvr.Cells.Add(t d1)

' BP trend info
Dim td2 As TableCell = New TableCell
td2.Text = "TREND-BULLISH PERCENT"
td2.ColumnSpan = 3
td2.HorizontalA lign = HorizontalAlign .Center
gvr.Cells.Add(t d2)
' 2 percent Short term
Dim td4 As TableCell = New TableCell
td4.Text = "SHORT TERM"
td4.ColumnSpan = 3
td4.HorizontalA lign = HorizontalAlign .Center
gvr.Cells.Add(t d4)

' 4 Intermediate
Dim td5 As TableCell = New TableCell
td5.Text = "INTERMEDIA TE TERM"
td5.ColumnSpan = 3
td5.HorizontalA lign = HorizontalAlign .Center
gvr.Cells.Add(t d5)

' 6 long term
Dim td6 As TableCell = New TableCell
td6.Text = "LONG TERM"
td6.ColumnSpan = 2
td6.HorizontalA lign = HorizontalAlign .Center
gvr.Cells.Add(t d6)

'10 week Momentum
Dim td3 As TableCell = New TableCell
td3.Text = "MOMENTUM 10 WEEK"
td3.HorizontalA lign = HorizontalAlign .Center
td3.ColumnSpan = 3
gvr.Cells.Add(t d3)

'ok add filler fro rest
'Dim td99 As TableCell = New TableCell
'td99.Text = " "
'td99.ColumnSpa n = 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.HorizontalA lign = 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 insertExtraHead er(object sender, EventArgs e)
{
GridView gv = this.gvSSShot;
GridViewRow gvr0 = new GridViewRow(0, 0, DataControlRowT ype.Header,
DataControlRowS tate.Insert);
GridViewRow gvr = new GridViewRow(0, 0, DataControlRowT ype.Header,
DataControlRowS tate.Insert);

// insert the top header row
TableCell td0 = new TableCell();
td0.Text = "SECTOR SNAP SHOT";
td0.HorizontalA lign = HorizontalAlign .Center;
td0.Font.Size = FontUnit.Large;
td0.ColumnSpan = 17;
gvr0.Cells.Add( td0);
TableCell td = new TableCell();
td.Text = Html32TextWrite r.SpaceChar.ToS tring();
td.ColumnSpan = 0;
gvr.Cells.Add(t d);

TableCell td1 = new TableCell();
td1.Text = "RATING";
td1.ColumnSpan = 2;
td1.HorizontalA lign = HorizontalAlign .Center;
gvr.Cells.Add(t d1);

// BP trend info
TableCell td2 = new TableCell();
td2.Text = "TREND-BULLISH PERCENT";
td2.ColumnSpan = 3;
td2.HorizontalA lign = HorizontalAlign .Center;
gvr.Cells.Add(t d2);
//' 2 percent Short term
TableCell td4 = new TableCell();
td4.Text = "SHORT TERM";
td4.ColumnSpan = 3;
td4.HorizontalA lign = HorizontalAlign .Center;
gvr.Cells.Add(t d4);

///' 4 Intermediate
TableCell td5 = new TableCell();
td5.Text = "INTERMEDIA TE TERM";
td5.ColumnSpan = 3;
td5.HorizontalA lign = HorizontalAlign .Center;
gvr.Cells.Add(t d5);

//' 6 long term
TableCell td6 = new TableCell();
td6.Text = "LONG TERM";
td6.ColumnSpan = 2;
td6.HorizontalA lign = HorizontalAlign .Center;
gvr.Cells.Add(t d6);

//'10 week Momentum
TableCell td3 = new TableCell();
td3.Text = "MOMENTUM 10 WEEK";
td3.HorizontalA lign = HorizontalAlign .Center;
td3.ColumnSpan = 3;
gvr.Cells.Add(t d3);

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" wrote:
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
>
>
"WebBuilder 451" wrote:
>
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
Sep 12 '07 #5
ok, the real problem! the event was not wired up correctly to the rowdatabound!
Rowcreated is the wrong place for this. And for some reason VS did not
correctly wire up the event.

Thanks!! you helped me solve the issue.

--
(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" wrote:
Here is an actual automated conversion (from Instant C#).
Although it's a good learning situation to convert by hand, I think you will
run into a lot of problems doing this - right off the top, the type of your
'e' parameter was wrong.
protected void InsertExtraHead er(object sender,
System.Web.UI.W ebControls.Grid ViewRowEventArg s e)
{
// Custom super header row
GridView gv = (GridView)sende r;
GridViewRow gvr0 = new GridViewRow(0, 0, DataControlRowT ype.Header,
DataControlRowS tate.Insert);
GridViewRow gvr = new GridViewRow(0, 0, DataControlRowT ype.Header,
DataControlRowS tate.Insert);
TableCell TD = new TableCell();
// add first new header spacer
TD.Text = HtmlTextWriter. SpaceChar;
TD.ColumnSpan = 0;
gvr.Cells.Add(T D);

//add ratine subheader
TableCell td1 = new TableCell();
td1.Text = "RATING";
td1.ColumnSpan = 2;
td1.HorizontalA lign = HorizontalAlign .Center;
gvr.Cells.Add(t d1);

// BP trend info
TableCell td2 = new TableCell();
td2.Text = "TREND-BULLISH PERCENT";
td2.ColumnSpan = 3;
td2.HorizontalA lign = HorizontalAlign .Center;
gvr.Cells.Add(t d2);
// 2 percent Short term
TableCell td4 = new TableCell();
td4.Text = "SHORT TERM";
td4.ColumnSpan = 3;
td4.HorizontalA lign = HorizontalAlign .Center;
gvr.Cells.Add(t d4);

// 4 Intermediate
TableCell td5 = new TableCell();
td5.Text = "INTERMEDIA TE TERM";
td5.ColumnSpan = 3;
td5.HorizontalA lign = HorizontalAlign .Center;
gvr.Cells.Add(t d5);

// 6 long term
TableCell td6 = new TableCell();
td6.Text = "LONG TERM";
td6.ColumnSpan = 2;
td6.HorizontalA lign = HorizontalAlign .Center;
gvr.Cells.Add(t d6);

//10 week Momentum
TableCell td3 = new TableCell();
td3.Text = "MOMENTUM 10 WEEK";
td3.HorizontalA lign = HorizontalAlign .Center;
td3.ColumnSpan = 3;
gvr.Cells.Add(t d3);

//ok add filler fro rest
//Dim td99 As TableCell = New TableCell
//td99.Text = " "
//td99.ColumnSpan = 7
//gvr.Cells.Add(t d99)
//add the new header row
gv.Controls[0].Controls.AddAt (0, gvr);

//insert the top header row
TableCell td0 = new TableCell();
td0.Text = "SECTOR SNAP SHOT";
td0.HorizontalA lign = HorizontalAlign .Center;
td0.Font.Size = FontUnit.Large;
td0.ColumnSpan = 17;
gvr0.Cells.Add( td0);
gv.Controls[0].Controls.AddAt (0, gvr0);
}

--
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
"WebBuilder 451" wrote:
it's a lot of code, sorry about the size
1st vb.net , this works
Protected Sub InsertExtraHead er(ByVal sender As Object, ByVal e As
System.Web.UI.W ebControls.Grid ViewRowEventArg s)
' Custom super header row
Dim gv As GridView = sender
Dim gvr0 As GridViewRow = New GridViewRow(0, 0,
DataControlRowT ype.Header, DataControlRowS tate.Insert)
Dim gvr As GridViewRow = New GridViewRow(0, 0,
DataControlRowT ype.Header, DataControlRowS tate.Insert)
Dim TD As TableCell = New TableCell
' add first new header spacer
TD.Text = HtmlTextWriter. SpaceChar
TD.ColumnSpan = 0
gvr.Cells.Add(T D)

'add ratine subheader
Dim td1 As TableCell = New TableCell
td1.Text = "RATING"
td1.ColumnSpan = 2
td1.HorizontalA lign = HorizontalAlign .Center
gvr.Cells.Add(t d1)

' BP trend info
Dim td2 As TableCell = New TableCell
td2.Text = "TREND-BULLISH PERCENT"
td2.ColumnSpan = 3
td2.HorizontalA lign = HorizontalAlign .Center
gvr.Cells.Add(t d2)
' 2 percent Short term
Dim td4 As TableCell = New TableCell
td4.Text = "SHORT TERM"
td4.ColumnSpan = 3
td4.HorizontalA lign = HorizontalAlign .Center
gvr.Cells.Add(t d4)

' 4 Intermediate
Dim td5 As TableCell = New TableCell
td5.Text = "INTERMEDIA TE TERM"
td5.ColumnSpan = 3
td5.HorizontalA lign = HorizontalAlign .Center
gvr.Cells.Add(t d5)

' 6 long term
Dim td6 As TableCell = New TableCell
td6.Text = "LONG TERM"
td6.ColumnSpan = 2
td6.HorizontalA lign = HorizontalAlign .Center
gvr.Cells.Add(t d6)

'10 week Momentum
Dim td3 As TableCell = New TableCell
td3.Text = "MOMENTUM 10 WEEK"
td3.HorizontalA lign = HorizontalAlign .Center
td3.ColumnSpan = 3
gvr.Cells.Add(t d3)

'ok add filler fro rest
'Dim td99 As TableCell = New TableCell
'td99.Text = " "
'td99.ColumnSpa n = 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.HorizontalA lign = 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 insertExtraHead er(object sender, EventArgs e)
{
GridView gv = this.gvSSShot;
GridViewRow gvr0 = new GridViewRow(0, 0, DataControlRowT ype.Header,
DataControlRowS tate.Insert);
GridViewRow gvr = new GridViewRow(0, 0, DataControlRowT ype.Header,
DataControlRowS tate.Insert);

// insert the top header row
TableCell td0 = new TableCell();
td0.Text = "SECTOR SNAP SHOT";
td0.HorizontalA lign = HorizontalAlign .Center;
td0.Font.Size = FontUnit.Large;
td0.ColumnSpan = 17;
gvr0.Cells.Add( td0);
TableCell td = new TableCell();
td.Text = Html32TextWrite r.SpaceChar.ToS tring();
td.ColumnSpan = 0;
gvr.Cells.Add(t d);

TableCell td1 = new TableCell();
td1.Text = "RATING";
td1.ColumnSpan = 2;
td1.HorizontalA lign = HorizontalAlign .Center;
gvr.Cells.Add(t d1);

// BP trend info
TableCell td2 = new TableCell();
td2.Text = "TREND-BULLISH PERCENT";
td2.ColumnSpan = 3;
td2.HorizontalA lign = HorizontalAlign .Center;
gvr.Cells.Add(t d2);
//' 2 percent Short term
TableCell td4 = new TableCell();
td4.Text = "SHORT TERM";
td4.ColumnSpan = 3;
td4.HorizontalA lign = HorizontalAlign .Center;
gvr.Cells.Add(t d4);

///' 4 Intermediate
TableCell td5 = new TableCell();
td5.Text = "INTERMEDIA TE TERM";
td5.ColumnSpan = 3;
td5.HorizontalA lign = HorizontalAlign .Center;
gvr.Cells.Add(t d5);

//' 6 long term
TableCell td6 = new TableCell();
td6.Text = "LONG TERM";
td6.ColumnSpan = 2;
td6.HorizontalA lign = HorizontalAlign .Center;
gvr.Cells.Add(t d6);

//'10 week Momentum
TableCell td3 = new TableCell();
td3.Text = "MOMENTUM 10 WEEK";
td3.HorizontalA lign = HorizontalAlign .Center;
td3.ColumnSpan = 3;
gvr.Cells.Add(t d3);

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" wrote:
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
>
>
"WebBuilder 451" wrote:
>
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
Sep 12 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
9356
by: Miguel Dias Moura | last post by:
Hello, I have a GridView in my page which is created in runtime. It works fine. My page has 2 Asp Buttons: - The HIDE button makes GridView.Visible = False; - The SHOW button makes GridView.Visible = True. I press HIDE and the GridView disappears as expected. After it I press SHOW and the GridView doesn't show.
2
2762
by: Flinky Wisty Pomm | last post by:
Hi all, I've got a really annoying problem that I need to fix sharpish. I've got a GridView derived control which has a templated header and footer. It works wonderfully on the first render but then the header/footer vanish into thin air. If I add the header/footer onDataBound then they disappear when I do a postback with no databinding. If I add them during PreRender, then they persist, but one of my data rows is emptied for each time I...
1
4976
by: Stu Lock | last post by:
Hi, I've spent the last hour trawling google for this - but all I find are people asking the same question! I have a gridview which is being databound to an empty datasource. I can display the 'EmptyDataText' no problem, but the header and footer do not display. The header I can live without - but the footer contains the 'Add new item' form elements, so needs to be visible when the grid is empty.
0
3584
by: DC | last post by:
The problem I'm using the .NET GridView and FormView objects for the first time and im getting the error "An OleDbParameter with ParameterName '@ID' is not contained by this OleDbParameterCollection" whenI try to write a new record. Delete and Modify work fine its just the add record function causes the error.
8
7736
by: gerry | last post by:
The PagerSettings.Visible property is not being handled properly by the GridView control. The value assigned to this property is not applied until after a postback. Simplest test : .aspx containing a single gridview - enable paging and give enough data to page. add checkbox with auto postback enable add button with auto postback enable in the GridView1_PreRender method add the following : GridView1.HeaderRow.Enabled =
4
19499
by: tirath | last post by:
hi, I want to display data in on my web page, in gridview in this format: Group A Group B A1 A2 B1 B2 Test 1 1 2 1 2 Test 2 1 2 1 2 Group A is header to columns A1 and A2 and Group B is header to columns B1 and B2. How do i add header to columns A1 A2 and B1 B2?
2
7171
by: Tim | last post by:
I'm using a GridView with its DataSource property set to a DataTable. During the RowDataBound event, the first row of the DataTable is reported as a DataControlRowType.Header instead of DataControlRowType.DataRow. How do I change this behavior? Right now, I ignore the RowType and just assume all rows are actually data rows (which in fact they are). However, this bugs me, so I'm wondering if any one knows how to "properly" work around...
7
12956
by: rote | last post by:
I would like to make my Gridview header dynmic i.e databinded from database.. I want my users to be able to change the headers on the fly.. Any ideas?
2
5404
by: gnewsgroup | last post by:
I have a GridView, in which the header of one column changes depending on the selected value of a DropDownList outside of this GridView. I did this dynamic header through protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.Header) {
0
9568
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9399
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10007
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9957
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9835
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8832
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5276
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5423
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.