Empty datagrid in ASP.NET
I dont understand.
I am using this collection object to fill the data from database. I am using this colleciton object and constructing a datatable and later i am binding this datatable to the datagrid, but to my dismay, its not showing anything on screen. Well, when i debug i can see the data, but some how, the datagrid is not taking data from the datatable
here is the sample code
private void Page_Load(object sender, System.EventArgs e)
{
//Set Today's date and time information
lblDate.Text=DateTime.Now.ToShortDateString().ToString() + " " + DateTime.Now.ToShortTimeString().ToString();
//DataGrid dgMainTopic=new DataGrid();
if(!IsPostBack)
{
//Populate the grid with the data for maintopics
DataTable dgTable= PopulateMainTopicGrid();
dgMainTopic.DataSource=dgTable;
dgMainTopic.DataBind();
}
}
private DataTable PopulateMainTopicGrid()
{
try
{
MBoard.MainTopicService.MainTopicsService MTService=new MBoard.MainTopicService.MainTopicsService();
MBoard.BoardCollection GridCollection=new MBoard.BoardCollection();
MBoard.MainTopicInfo.MainTopicInfo MTInfo=new MBoard.MainTopicInfo.MainTopicInfo();
GridCollection=MTService.getAllMainTopics();
DataTable dtMTopic=new DataTable();
DataRow drTopicRow;
DataColumn drTopicCol;
//Add all the column headers
//Forum Topics Messages LastPost
drTopicCol=new DataColumn();
drTopicCol.Caption="Forums";
drTopicCol.ColumnName="Forums";
dtMTopic.Columns.Add(drTopicCol);
drTopicCol=new DataColumn();
drTopicCol.Caption="Topics";
drTopicCol.ColumnName="Topics";
dtMTopic.Columns.Add(drTopicCol);
drTopicCol=new DataColumn();
drTopicCol.Caption="Messages";
drTopicCol.ColumnName="Messages";
dtMTopic.Columns.Add(drTopicCol);
drTopicCol=new DataColumn();
drTopicCol.Caption="LastPost";
drTopicCol.ColumnName="LastPost";
dtMTopic.Columns.Add(drTopicCol);
//Add all the rows(Data from the database)
for(int i=0;i