By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,649 Members | 1,572 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,649 IT Pros & Developers. It's quick & easy.

vb vs cs gridview header question

P: n/a
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
Share this Question
Share on Google+
5 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.