foreach (DataRow dr in drFiltered)
{
dtTemp.ImportRow(dr);
}
//Another approach for filtering the contents , But execution time is more , so only acceptable for smaller amount of datarows.
DataView dv = new DataView(dtTemp);
dv.Sort = ("SLNO");
dtTemp = dv.ToTable();
// Storing of records during page postback..
//One idea can be to store this table in viestate and retrive values from the viewstate each time.
ViewState["TempTable"] = dtTemp;
//Bind to the databinding control
ListView1.DataSource = dtTemp;
ListView1.DataBind();
}
if (Page.IsPostBack)
{
// On each postback retrive the datatable from the view state
if (ViewState["TempTable"] != null)
{
dtTemp = (DataTable)ViewState["TempTable"];
}
//Bind to the databinding control
ListView1.DataSource = dtTemp;
ListView1.DataBind();
}
Note: The above approach should not be taken when working with large number of records as it may adversely affect performance