<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" OnPageIndexChanging="GridView1_PageIndexChanging"
PageSize="5" AllowPaging="True" AllowSorting="true" OnRowEditing="GridView1_RowEditing"
OnSorting="gridView1_Sorting">
<Columns>
<asp:TemplateField SortExpression="Tital" >
<HeaderTemplate>
Tital</HeaderTemplate>
<ItemTemplate>
<asp:Label ID="lbltital" runat="server" Text='<%#Eval("Tital")%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
Obj.Fillgrid(GridView1, "Select PK_ID,Tital From Aboutus");
}
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
}
protected void gridView1_Sorting(object sender, GridViewSortEventArgs e)
{
//(GridView1.DataSource.GetType()); //Add this line
DataTable m_DataTable = GridView1.DataSource as DataTable;
if (m_DataTable != null)
{
DataView m_DataView = new DataView(m_DataTable);
m_DataView.Sort = e.SortExpression + " " + e.SortDirection;
GridView1.DataSource = m_DataView;
GridView1.DataBind();
}
}
--------------------------------------------------------------------------------------------
DataTable dt = Obj.getdata("Select PK_ID,Tital From Aboutus");
if (ViewState["dir"] != null)
{
if (ViewState["dir"].ToString() == "ASC")
{
ViewState["dir"] = "DESC";
}
else { ViewState["dir"] = "ASC"; }
}
else
{
ViewState["dir"] = "ASC";
}
dt.DefaultView.Sort = e.SortExpression + " " + ViewState["dir"].ToString();
GridView1.DataSource = dt;
GridView1.DataBind();
-------------------------------------------------------------------------------------------------
PageSize="5" AllowPaging="True" AllowSorting="true" OnRowEditing="GridView1_RowEditing"
OnSorting="gridView1_Sorting">
<Columns>
<asp:TemplateField SortExpression="Tital" >
<HeaderTemplate>
Tital</HeaderTemplate>
<ItemTemplate>
<asp:Label ID="lbltital" runat="server" Text='<%#Eval("Tital")%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
Obj.Fillgrid(GridView1, "Select PK_ID,Tital From Aboutus");
}
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
}
protected void gridView1_Sorting(object sender, GridViewSortEventArgs e)
{
//(GridView1.DataSource.GetType()); //Add this line
DataTable m_DataTable = GridView1.DataSource as DataTable;
if (m_DataTable != null)
{
DataView m_DataView = new DataView(m_DataTable);
m_DataView.Sort = e.SortExpression + " " + e.SortDirection;
GridView1.DataSource = m_DataView;
GridView1.DataBind();
}
}
--------------------------------------------------------------------------------------------
DataTable dt = Obj.getdata("Select PK_ID,Tital From Aboutus");
if (ViewState["dir"] != null)
{
if (ViewState["dir"].ToString() == "ASC")
{
ViewState["dir"] = "DESC";
}
else { ViewState["dir"] = "ASC"; }
}
else
{
ViewState["dir"] = "ASC";
}
dt.DefaultView.Sort = e.SortExpression + " " + ViewState["dir"].ToString();
GridView1.DataSource = dt;
GridView1.DataBind();
-------------------------------------------------------------------------------------------------
No comments:
Post a Comment