i want to sort my gridview according to the datakeyname id in descending order:
but the code not working
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
ViewState["sortexp"] = "";
ViewState["orderby"] = "ASC";
BindGridData();
}
}
protected void BindGridData()
{
string sql = @"Data Source=SAJITH-PC\SQLEXPRESS;Initial Catalog=myfile1;Integrated Security=True";
SqlConnection con = new SqlConnection(sql);
SqlCommand com = new SqlCommand();
con.Open();
SqlCommand cmd = new SqlCommand("Select top 3 id,username,dept,costcode,mobileno,pickupdate,pickuptime,fromdest,todest,notes,status from main where hodusername='" + Session["hodusername"] + "'", con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new ...
Go to the complete details ...