C# 使用dropdownlist显示表格中的选定值
我需要根据用户的主要类型显示用户详细信息,如果用户将从dropdownlist中选择parent,我希望表格仅显示主要类型值为1的用户,或值为2的教师等 这是我的密码C# 使用dropdownlist显示表格中的选定值,c#,html,.net,asp.net-mvc,C#,Html,.net,Asp.net Mvc,我需要根据用户的主要类型显示用户详细信息,如果用户将从dropdownlist中选择parent,我希望表格仅显示主要类型值为1的用户,或值为2的教师等 这是我的密码 <div class="row"> <asp:DropDownList runat="server" onclickEvent="DropDownSelect"> <asp:ListItem></asp:ListItem&g
<div class="row">
<asp:DropDownList runat="server" onclickEvent="DropDownSelect">
<asp:ListItem></asp:ListItem>
<asp:ListItem Value="1">Parent</asp:ListItem>
<asp:ListItem Value="2">Teacher</asp:ListItem>
<asp:ListItem Value="3">User</asp:ListItem>
<asp:ListItem Value="4">Student</asp:ListItem>
</asp:DropDownList>
</div>
<h2 class="panel-title">Users List</h2>
</header>
<div class="panel-body">
<asp:GridView runat="server" PageSize="15" AllowPaging="True" DataSourceID="userDS" AutoGenerateColumns="False" CssClass="table table-bordered table-striped mb-none">
<PagerStyle CssClass="dataTables_paginate paging_bs_normal" HorizontalAlign="Left"
VerticalAlign="Middle"
Font-Size="14pt" Wrap="True" />
<Columns>
<asp:boundfield datafield="userName" headertext="Username"/>
<asp:boundfield datafield="eMailAddress" headertext="Email Address"/>
<asp:boundfield datafield="firstName" headertext="First Name"/>
<asp:boundfield datafield="lastName" headertext="Last Name"/>
<asp:boundfield datafield="organization" headertext="Organization"/>
<asp:boundfield datafield="roletitle" headertext="Role"/>
<asp:boundfield datafield="city" headertext="City"/>
<asp:boundfield datafield="primaryType" headertext="P. Type"/>
<asp:boundfield datafield="state" headertext="State"/>
<asp:boundfield datafield="accessCodeUsed" headertext="Access Code"/>
<asp:TemplateField>
<ItemTemplate>
<a class="modal-with-form btn btn-default editUserButton" href="#modalForm">Edit</a>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<a class="mb-xs mt-xs mr-xs modal-basic btn btn-danger deleteUserButton" href="#modalDeleteUser">Delete</a>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
请参阅下面的文章,了解与您类似的场景以及如何解决此问题 基本上,您需要始终为Asp.NET中的所有服务器端HTML控件提供“ID”值。此外,如果需要在用户更改其值时执行某些操作,请将DropDownList等控件的AutoPostBack属性设置为true。在您的例子中,您只需要刷新表(即,另一个控件的数据源),您不需要编写事件处理程序,您只需应用过滤器表达式,如给定链接所述