HighTechTalks DotNet Forums  

Extra line in GridView

ASP.net Data Grid Control microsoft.public.dotnet.framework.aspnet.datagridcontrol


Discuss Extra line in GridView in the ASP.net Data Grid Control forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
John Doe
 
Posts: n/a

Default Extra line in GridView - 04-19-2007 , 01:59 PM






Why am I am getting an extra line in GridView with the following text in the
1st column: "System.Web.UI.WebControls.TableRow"


Here's partial listing of my code:
...................
grid.DataSource = loadTable(ds);
grid.DataBind();
..................
private DataTable loadTable(DataSet ds)
{
DataTable dt = new DataTable();
DataTable myDataTable = ds.Tables[1];
int cols = myDataTable.Columns.Count;


TableHeaderRow thr = new TableHeaderRow();
for(int i = 0; i < cols; i++)
{
TableHeaderCell thc = new TableHeaderCell();
thc.Text = myDataTable.Columns[i].ColumnName;
thr.Cells.Add(thc);

DataColumn dcol = new DataColumn(thc.Text,
typeof(System.String));
dt.Columns.Add(dcol);
}
dt.Rows.Add(thr);
return dt;
}




Reply With Quote
  #2  
Old   
Alvin Bruney [MVP]
 
Posts: n/a

Default Re: Extra line in GridView - 04-20-2007 , 07:46 AM






It's most likely an empty row.

--
Regards,
Alvin Bruney
------------------------------------------------------
Shameless author plug
Excel Services for .NET is coming...
OWC Black book on Amazon and
www.lulu.com/owc
Professional VSTO 2005 - Wrox/Wiley


"John Doe" <jdoe (AT) msn (DOT) com> wrote

Quote:
Why am I am getting an extra line in GridView with the following text in
the 1st column: "System.Web.UI.WebControls.TableRow"


Here's partial listing of my code:
..................
grid.DataSource = loadTable(ds);
grid.DataBind();
.................
private DataTable loadTable(DataSet ds)
{
DataTable dt = new DataTable();
DataTable myDataTable = ds.Tables[1];
int cols = myDataTable.Columns.Count;


TableHeaderRow thr = new TableHeaderRow();
for(int i = 0; i < cols; i++)
{
TableHeaderCell thc = new TableHeaderCell();
thc.Text = myDataTable.Columns[i].ColumnName;
thr.Cells.Add(thc);

DataColumn dcol = new DataColumn(thc.Text,
typeof(System.String));
dt.Columns.Add(dcol);
}
dt.Rows.Add(thr);
return dt;
}






Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.