الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

Problem In Sort Gridview

بدأه sp88 في 18 يوليو 2008 · 1 رد · 550 مشاهدة · في ASP.NET
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

slam alikom w r7mt allah

this is my code for sort

but it is never excute ,it just fired but no change

file.aspx.cs

//Sorting Code

private DataSet GetData()

{

string ConnectionString = ClsConSt.ReturnStringConnection();

SqlConnection myConnection = new SqlConnection(ConnectionString);

SqlDataAdapter ad = new SqlDataAdapter("SELECT * FROM Food_List", myConnection);

ad.Fill(ds);

return ds;

}

public SortDirection GridViewSortDirection

{

get

{

if (ViewState["sortDirection"] == null)

ViewState["sortDirection"] = SortDirection.Ascending;

return (SortDirection)ViewState["sortDirection"];

}

set { ViewState["sortDirection"] = value; }

}

protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)

{

string sortExpression = e.SortExpression;

if (GridViewSortDirection == SortDirection.Ascending)

{

GridViewSortDirection = SortDirection.Descending;

SortGridView(sortExpression, " DESC");

}

else

{

GridViewSortDirection = SortDirection.Ascending;

SortGridView(sortExpression, " ASC");

}

}

private void SortGridView(string sortExpression, string direction)

{

// You can cache the DataTable for improving performance

DataTable dt = GetData().Tables[0];

DataView dv = new DataView(dt);

dv.Sort = sortExpression+""+direction;

FoodsGridView.DataSource = dv;

FoodsGridView.DataBind();

}

file.aspx

<asp:GridView ID="FoodsGridView" runat="server" AutoGenerateColumns=False AllowSorting="True" Height="117px"

OnRowCreated="FoodsGridView_RowCreated1"

OnSorting="GridView1_Sorting">

plz help meeeee

any body have easier way,plz send to me

#2

يا جماعه محتاج الكود ده ضرورى

ياريت اللى عنده كود لعمل

sort to gridview without datasource

ياريت يبعته بسرعه

لانى محتاجه اوى

وشكرا لكم

والسلام عليكم

مواضيع مشابهة

عدد الزوار حالياً

المتواجدون خلال آخر ساعة · يتحدّث كل ٣٠ ثانية

—الإجمالي—أعضاء مسجّلون—زوار بدون تسجيل

جارٍ التحقق من المتواجدين…