TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
chandu gummadi
NA
67
73.2k
gridview sorting in asp.net using c#
Apr 8 2013 3:39 AM
HI friends iam developing grid view sorting application in asp .net.
iam writting bellow code but its not working properly.
grid view sorting is done for one column and sorting is not done for another column it shows error like "
INVALID COLUMN EMPNAME"
PLEASE SOLVE MY PROBLEM.
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();
dv.Sort = string.Concat(sortExpression, " ", sortDirection);
}
GVChangePwd.DataSource = dv;
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();
}
Reply
Answers (
1
)
how we can add the two number
save date in database in DD-MM-YYYY format.