私の要件は、私は、データベースからすべてのデータがグリッドビューのデータソースを更新せずに グリッドビューにバインドする必要がありたいということです....GridViewのデータソースを更新
ここは私のコードは次のとおりです。 -
public void BindAll(GridView grd)
{
List<int> id = new List<int>();
SqlCommand cmd =new SqlCommand("Select SiteId from SiteMaster",con);
con.Open();
SqlDataReader dr =cmd.ExecuteReader();
while (dr.Read())
{
id.Add(Convert.ToInt16(dr["SiteId"]));
}
dr.Close();
foreach (int k in id)
{
List<Errorlog> lst = new List<Errorlog>();
DynamicParameters param = new DynamicParameters();
param.Add("SiteId",k, DbType.Int16);
lst = con.Query<Errorlog>("Usp_Temp", param, null, true, 200, CommandType.StoredProcedure).ToList();
if (lst.Count != 0)
{
grd.DataSource = lst; //here it display only those record which are last updated.I am binding data from multiple table .it only display last table data.I want all the data from all the table should be display.
grd.DataBind();
}
}
}
私はlstを一度だけ更新したくないです。リスト lst = newリスト();古いデータを削除するたびに新しいリストを作成しています。また、設定されたデータソースをnullに更新する場合:grd.DataSource = null; grd.DataSource = lst; –
jdweng