Hi friends iam implementing the gridview sorting in my application but sorting is not done for all rows.
it shows a error like "can not fine column name empname".
iam using bellow code
public void BindGVPasswordChange()
{
try
{
DataTable dt = new DataTable();
Hashtable htnew = new Hashtable();
htnew.Add("PwdId", 0);
dt = _sec.getDataTable("Stp_UM_FillGV_Changepasswords", CommandType.StoredProcedure, htnew);
if (dt.Rows.Count > 0)
{
DataView dv = dt.DefaultView;
if (ViewState["SortDirection"] != null)
{
sortDirection = ViewState["SortDirection"].ToString();
}
if (ViewState["SortExpression"] != null)
{
sortExpression = ViewState["SortExpression"].ToString();
string sort = string.Concat(sortExpression, " ", sortDirection);
dv.Sort = string.Concat(sortExpression, " ", sortDirection);
}
GVChangePwd.DataSource = dv;
GVChangePwd.DataSource = dt;
GVChangePwd.DataBind();
}
GVChangePwd.Visible = true;
}
catch (Exception ex)
{
}
}
protected void GVChangePwd_Sorting(object sender, GridViewSortEventArgs e)
{
if (ViewState["SortDirection"] == null || ViewState["SortExpression"].ToString() != e.SortExpression)
{
ViewState["SortDirection"] = "ASC";
GVChangePwd.PageIndex = 0;
}
else if (ViewState["SortDirection"].ToString() == "ASC")
{
ViewState["SortDirection"] = "DESC";
}
else if (ViewState["SortDirection"].ToString() == "DESC")
{
ViewState["SortDirection"] = "ASC";
}
ViewState["SortExpression"] = e.SortExpression;
BindGVPasswordChange();
}
please help me..
Loading
chandu gummadiPosted May 2, 2013, 3:54 AM
Satyapriya NayakPosted May 2, 2013, 3:47 AM
http://www.c-sharpcorner.com/uploadfile/suthish_nair/gridview-sorting-paging-without-using-session-viewstate-or-cache/default.aspx
http://www.c-sharpcorner.com/uploadfile/Salceson/fancy-gridview-sorting/default.aspx
http://www.c-sharpcorner.com/UploadFile/rohatash/sort-the-gridview-column-using-dataview-in-Asp-Net/
Pankaj PandeyPosted May 2, 2013, 3:01 AM
please specify sorting expression which field you are using for sorting ,you didn't specified in code.
may be above error causes due to this reason.
try it after giving field name with sorting expression