2013-07-01 25 views
0

我有一个下拉菜单,它会影响我对gridview的select语句。如果我刷新页面,则根据选择正确更新网格。使用C刷新Gridview使用C#

protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) 
{ 
    SqlDataSource4.SelectParameters["userIdSelected"].DefaultValue = userNameDropDown.SelectedItem.Value; 
    //update grid here 
    } 

当我的下拉列表更改时,如何查看更新的网格?

+0

这听起来像你需要将你的DropDownList的AutoPostback属性设置为true,但目前尚不清楚。 – called2voyage

+0

我感觉很傻,但是工作。 –

+0

[Asp.Net gridview自定义]的可能重复(http://stackoverflow.com/questions/2829220/asp-net-gridview-customization) – called2voyage

回答

2

您可以将DropDownList的AutoPostback属性设置为true。我建议你也使用UpdatePanel。

你可以阅读here了解更多关于UpdatePanel的信息。