Click here to Skip to main content
15,905,233 members

Comments by Jeevitha royapathi (Top 3 by date)

Jeevitha royapathi 20-Feb-12 6:32am View    
AGe dosent matter for a programmer/developer untill he enjoys coding....
Jeevitha royapathi 20-Feb-12 6:20am View    
private void LoadGrid(string sortExpr, string sortDirection)
{


DataSet ds = new DataSet();
SqlDataAdapter SqlDA = new SqlDataAdapter("Select * from tablename order by "+sortExpr+" "+sortDirection+"", connectionString);
SqlDA.Fill(ds);
if (ds != null)
{
gdManageForm.DataSource = ds;
gdManageForm.EditIndex = -1;
gdManageForm.DataBind();
}

}

protected void gdManageForm_Sorting(object sender, GridViewSortEventArgs e)
{
pnlform.Controls.Clear();
divformName.Style.Add("display", "none");
lblDispError.Text = "";
litFormName.Text = "";
string sortExpression = e.SortExpression;
ViewState["SortExpression"] = sortExpression;
if (GridViewSortDirection == SortDirection.Ascending)
{
GridViewSortDirection = SortDirection.Descending;
SortGridView(sortExpression, DESCENDING);
}
else
{
GridViewSortDirection = SortDirection.Ascending;
SortGridView(sortExpression, ASCENDING);
}
}

private void SortGridView(string sortExpression, string direction)
{
//If it is default state
LoadGrid(sortExpression, direction);
}

private SortDirection GridViewSortDirection
{
get
{
if (ViewState["sortDirection"] == null)
ViewState["sortDirection"] = SortDirection.Ascending;
return (SortDirection)ViewState["sortDirection"];
}
set { ViewState["sortDirection"] = value; }
}

Here gdManageForm is the GirdName
Jeevitha royapathi 16-Feb-12 6:50am View    
Use NameSpace "System.Web.UI" in cs page

and remove this code from design page
<asp:scriptmanager id="ScriptManager1" runat="server"/>