 |
|
ต้องการ sort ข้อมูลใน gridview ค่ะแล้วเกิด Error Page_gridview.SortCommand(object, System.Web.UI.WebControls.GridViewSortEventArgs)' is inaccessible due to its protection level |
|
 |
|
|
 |
 |
|
ดู code ทั้งหมดหน่อยครับ
|
 |
 |
 |
 |
Date :
2013-02-08 16:35:00 |
By :
kanchen |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (data.cs)
String strFields = "id_debt";
protected void Page_Load(object sender, EventArgs e)
{
}
void binddata()
{
string StrConn = WebConfigurationManager.ConnectionStrings["ConnectDB"].ToString();
SqlCommand objCmd = new SqlCommand();
SqlConnection Conn = new SqlConnection(StrConn);
// String condi = "where 1=1 ";
string sqlsm;
sqlsm = "select * from DEBT ORDER BY " + strFields + " ASC";
Conn.Open();
SqlDataAdapter da = new SqlDataAdapter(sqlsm, Conn);
DataSet ds = new DataSet();
da.Fill(ds, "DEBT");
gv.DataSource = ds.Tables["DEBT"];
gv.DataBind();
}
void Sort(object sender, GridViewSortEventArgs e)
{
strFields = e.SortExpression;
binddata();
}
protected void Button1_Click(object sender, EventArgs e)
{
binddata();
}
|
 |
 |
 |
 |
Date :
2013-02-08 17:02:40 |
By :
mushroomsn |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (C#)
protected void Page_Load(object sender, EventArgs e)
{
gridview.Sorted += new EventHandler(gridview_Sorted); // add event to gridview
}
protected void gridview_Sorted(object sender, GridViewSortEventArgs e)
{
}
แก้ไขเป็นแบบนี้น่ะครับ ต้องเป็น protected อย่างเดียวน่ะครับ
|
 |
 |
 |
 |
Date :
2013-02-08 17:14:00 |
By :
kanchen |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ได้แล้วค่ะ ขอบคุณ ใส่ protected ไปค่ะ
|
 |
 |
 |
 |
Date :
2013-02-08 17:34:43 |
By :
mushroomsn |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|