Note that there are some explanatory texts on larger screens.

plurals
  1. POSorting Gridview breaks ModalPopUp in GridView
    text
    copied!<p>I have a gridview that has linkbuttons that call modalpopups and textboxes with values. I am trying to implement sorting for the gridview, but the if(!ispostback) statement I need for sorting prevents the modalpopup from appearing. It also does not sort the textboxes in the gridview. Is there a way to implement sorting without using ispostback in the page_load?</p> <p>Here is the code for the modalpopup, gridview binding and sorting.</p> <pre><code>protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { ViewState["sortOrder"] = ""; Bind_Gridview("", ""); loadModals(); } } protected void viewModal(object sender, EventArgs e) { ... mainPanel.Controls.Add(exstModal); mainPanel.Controls.Add(exstModalBox); exstModalBox.Show(); } protected void GridView1_Sorting(object sender, GridViewSortEventArgs e) { Bind_Gridview(e.SortExpression, sortOrder); } public string sortOrder { get { if (ViewState["sortOrder"].ToString() == "desc") { ViewState["sortOrder"] = "asc"; } else { ViewState["sortOrder"] = "desc"; } return ViewState["sortOrder"].ToString(); } set { ViewState["sortOrder"] = value; } } protected void gv1_RowCommand(object sender, GridViewRowEventArgs e) { ... CheckBox cb = new CheckBox(); TextBox ca = new TextBox(); ca.Width = 20; TextBox cga = new TextBox(); cga.Width = 20; if (e.Row.RowType == DataControlRowType.DataRow) //Foreach row in gridview { while (dr1.Read()) { ca.Text = dr1["cyla"].ToString(); cga.Text = dr1["cga"].ToString(); checkText = dr1["completed"].ToString(); if (checkText == "True") { cb.Checked = true; } else { cb.Checked = false; } } ... dr1.Close(); conn1.Close(); e.Row.Cells[6].Controls.Add(ca); e.Row.Cells[8].Controls.Add(cga); e.Row.Cells[9].Controls.Add(cb); ... } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload