我有一個過濾用一個下拉框一個gridview。 GridView有LinkButtons,它們調用ModalPopUpExtender來顯示數據。一旦GridView被過濾並且單擊LinkButton,GridView過濾結果就會改變,數據也不正確。GridView的篩選結果更改ModalPopUpExtender調用後
<asp:DropDownList ID="ddl_temp" runat="server" AutoPostBack="True"
onselectedindexchanged="ddl_temp_SelectedIndexChanged">
<asp:ListItem>Select Status</asp:ListItem>
<asp:ListItem>Open</asp:ListItem>
<asp:ListItem>Closed</asp:ListItem>
</asp:DropDownList>
protected void tabs()
{
....
sds.FilterParameters.Clear();
sds.SelectParameters.Clear();
ControlParameter cp = new ControlParameter();
cp.ControlID = ddl_temp.ID.ToString();
cp.PropertyName = "SelectedValue";
cp.Name = "Status";
cp.Type = TypeCode.String;
cp.ConvertEmptyStringToNull = false;
sds.FilterParameters.Add(cp);
sds.ID = "sds1";
sds.SelectParameters.Add("sid", sid);
IssuesPanel.Controls.Add(sds);
BoundField date = new BoundField();
date.HeaderText = "Date";
date.DataField = dt.Columns[2].ToString();
date.SortExpression = dt.Columns[2].ToString();
BoundColumn bc = new BoundColumn();
bc.DataField = dt.Columns[2].ToString();
BoundField status = new BoundField();
status.HeaderText = "Status";
status.DataField = dt.Columns[3].ToString();
gv4 = new GridView();
gv4.DataSource = sds;
gv4.RowDataBound += gv4_RowCommand;
gv4.Columns.Add(date);
gv4.Columns.Add(status);
gv4.CellPadding = 6;
gv4.AutoGenerateColumns = false;
//gv4.AllowSorting = true;
gv4.AllowPaging = true;
gv4.DataBind();
IssuesPanel.Controls.Add(gv4);
...
}
protected void gv4_RowCommand(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
LinkButton lb = new LinkButton();
lb.Text = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "Title"));
lb.ID = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "Issue_ID"));
lb.Click += new EventHandler(issueModal);
e.Row.Cells[0].Controls.Add(lb);
}
}
protected void ddl_temp_SelectedIndexChanged(object sender, EventArgs e)
{
sds.FilterParameters.Clear();
ControlParameter cp = new ControlParameter();
cp.ControlID = ddl_temp.ID.ToString();
cp.PropertyName = "SelectedValue";
cp.Name = "Status";
cp.Type = TypeCode.String;
cp.ConvertEmptyStringToNull = false;
sds.FilterParameters.Add(cp);
sds.FilterExpression = "Status='{0}'";
gv4.DataSource = sds;
gv4.DataBind();
}
是這樣的WinForms或asp.net web表單?你需要更具體的 – Martin
這是一個asp.net的網頁表單 – Kianna
請標記您的問題,所以它變得更加具體 – Martin