简体   繁体   English

使用C#刷新Gridview

[英]refresh Gridview using C#

I have a dropdown menu that affects my select statement for a gridview. 我有一个下拉菜单,影响我对gridview的select语句。 The grid is updating correctly based on selection if I refresh the page. 如果我刷新页面,网格将根据选择正确更新。

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

How do I see the updated grid when my drop down list changes? 当下拉列表更改时,如何查看更新的网格?

You can set your DropDownList's AutoPostback attribute to true. 您可以将DropDownList的AutoPostback属性设置为true。 I suggest you use also an UpdatePanel. 我建议你也使用UpdatePanel。

You can read here to learn more about UpdatePanel. 您可以在此处阅读以了解有关UpdatePanel的更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM