0

在按钮单击事件上,我执行一个新查询,我得到一个新表,但我无法将它填充到同一个网格视图中。有什么原因我可以在哪里使用模式而不是数据表。

private void GetData()//This method Displays the Datatable onto the Grid
{            
    int intCount = 0;
    int.TryParse(txt_messagecount.Text, out intCount);
    DataTable dtData = null;
    //dtData = _objIMRSData.GetData(txt_fromdate.Text, txt_todata.Text, txt_messagecount.Text);
    dtData = _objIMRSData.GetTransactionData( txt_fromdate.Text, txt_todata.Text,intCount );           
    grd_transactionLog.DataSource = dtData;
    grd_transactionLog.DataBind();
    dtData.Clear();        
}

//On Button click event I execute a new query i get a new table 
//but i am unable to   populate it on to the same grid view
protected void btn_next_Click(object sender, EventArgs  e)
{ 
    int messageCount = int.Parse(txt_messagecount.Text);
    string lastRecord = grd_transactionLog.Rows[messageCount-1].Cells[1].Text;
    DataTable dtData1 = null;
    //dtData = _objIMRSData.GetData(lastRecord, txt_todata.Text, txt_messagecount.Text);
    dtData1 = _objIMRSData.GetTransactionData(lastRecord, txt_todata.Text, messageCount);
    //grd_transactionLog.Columns.Clear();            
    grd_transactionLog.DataSource = dtData1;
    grd_transactionLog.DataBind();
    dtData1.Clear();
}
4

1 回答 1

0

重新分配datasource. 在click事件中这样做。

grd_transactionLog.DataSource = null;
grd_transactionLog.DataSource = dtData1;
于 2013-09-27T18:16:14.433 回答