我定义了一个flexGrid绑定方法,每次添加一条数据就调用这个绑定方法,绑定后发现界面以前绑定的数据还在,也就是重复显示了,刷新也不行。每次添加之后调用下面的方法。
请问如何解决?
private void BindScheduleToGrid()
{
try
{
using (System.Data.SqlClient.SqlConnection dbConnection = new System.Data.SqlClient.SqlConnection(DBConnectString))
{
SqlCommand command = new SqlCommand();
command.Connection = dbConnection;
dbConnection.Open();
command.CommandText = "select * from tScheduleTime";
SqlDataAdapter myAdapter = new SqlDataAdapter(command);
myAdapter.Fill(_ds, "tScheduleTime");
command.CommandText = "select * from tScheduleTimePeriod";
myAdapter = new SqlDataAdapter(command);
myAdapter.Fill(_ds, "tScheduleTimePeriod");
_ds.Relations.Add("ScheduleTime_ScheduleTimePeriod", _ds.Tables["tScheduleTime"].Columns["UniqueID"], _ds.Tables["tScheduleTimePeriod"].Columns["ScheduleTimeUniqueID"]);
DataTable dt = _ds.Tables["tScheduleTime"];
dt.ExtendedProperties.Add("ShowColumns", new string[]{
"Alias,Alias","ModalityType,Modality Type ","ActionType,Action Type","Percent,Percent"
});
dt = _ds.Tables["tScheduleTimePeriod"];
dt.ExtendedProperties.Add("ShowColumns", new string[]{
"Alias,Alias","BeginTime,Begin Time","EndTime,End Time","Number"
});
_flex.SetDataBinding(_ds, "tScheduleTime");
_flex.Refresh();
}
}
catch
{
}
}
|
|