473,465 Members | 1,622 Online
Bytes | Software Development & Data Engineering Community
Create 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 1951
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
"WebBuilder451" 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 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" 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
"WebBuilder451" 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 InsertExtraHeader(object sender,
System.Web.UI.WebControls.GridViewRowEventArgs e)
{
// Custom super header row
GridView gv = (GridView)sender;
GridViewRow gvr0 = new GridViewRow(0, 0, DataControlRowType.Header,
DataControlRowState.Insert);
GridViewRow gvr = new GridViewRow(0, 0, DataControlRowType.Header,
DataControlRowState.Insert);
TableCell TD = new TableCell();
// add first new header spacer
TD.Text = HtmlTextWriter.SpaceChar;
TD.ColumnSpan = 0;
gvr.Cells.Add(TD);

//add ratine subheader
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);

//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
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);
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
"WebBuilder451" wrote:
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" 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
"WebBuilder451" 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_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Header)
this.InsertExtraHeader(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 InsertExtraHeader(object sender,
System.Web.UI.WebControls.GridViewRowEventArgs e)
{
// Custom super header row
GridView gv = (GridView)sender;
GridViewRow gvr0 = new GridViewRow(0, 0, DataControlRowType.Header,
DataControlRowState.Insert);
GridViewRow gvr = new GridViewRow(0, 0, DataControlRowType.Header,
DataControlRowState.Insert);
TableCell TD = new TableCell();
// add first new header spacer
TD.Text = HtmlTextWriter.SpaceChar;
TD.ColumnSpan = 0;
gvr.Cells.Add(TD);

//add ratine subheader
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);

//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
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);
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
"WebBuilder451" wrote:
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" 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
>
>
"WebBuilder451" 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 InsertExtraHeader(object sender,
System.Web.UI.WebControls.GridViewRowEventArgs e)
{
// Custom super header row
GridView gv = (GridView)sender;
GridViewRow gvr0 = new GridViewRow(0, 0, DataControlRowType.Header,
DataControlRowState.Insert);
GridViewRow gvr = new GridViewRow(0, 0, DataControlRowType.Header,
DataControlRowState.Insert);
TableCell TD = new TableCell();
// add first new header spacer
TD.Text = HtmlTextWriter.SpaceChar;
TD.ColumnSpan = 0;
gvr.Cells.Add(TD);

//add ratine subheader
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);

//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
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);
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
"WebBuilder451" wrote:
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" 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
>
>
"WebBuilder451" 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
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...
2
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...
1
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...
0
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...
8
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...
4
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...
2
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...
7
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
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
1
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...
0
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.