显示数据库中的所有用户,如果我选择任何用户,我需要显示所选用户的所有详细信息 [英] Display all users from Database and If I select anyone user, I need to show all details of the selected user
问题描述
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Groups <span class="caret"></span><span style="font-size:16px;" class="pull-right hidden-xs showopacity glyphicon glyphicon-user"></span></a>
<ul class="dropdown-menu forAnimate" role="menu">
<li ><a href="#">Group Details<span style="font-size:16px;" class="pull-right hidden-xs showopacity glyphicon glyphicon-th-list"><asp:DropDownList runat="server" CssClass="required form-control" ID="DropDownList1"></asp:DropDownList>
</span></a></li>
</ul>
</li>
i需要这个想法。 .how使用一个表id..plea从数据库中获取所有细节se any1帮助我..如果我从下拉列表中选择任意1个用户,它会显示该用户的所有详细信息...
请任何人都可以打电话给我关于c#
i need idea for this..how to fetch all the details from database using one table id..please any1 help me..If i select any1 user from dropdownlist,it shows all the details of that user...
please can anyone tel me about basic code..am beginner of c#
推荐答案
您好,请注意,您的用户表名为 AllUsers ,如下所示,
UserId UserName PhoneNumber 地址 User1 John 4567891234 Xyz User2 David 9987123456 Abc User3 Richard 8529784562 Def
现在只需使用以下选项从表中选择UserName查询,
Hi, Consider, you are having user table named "AllUsers" as follows,
UserId UserName PhoneNumber Address User1 John 4567891234 Xyz User2 David 9987123456 Abc User3 Richard 8529784562 Def
Now just select the UserName from the table using the following query,
Select UserName from AllUsers
它将返回UserNames列表。将此绑定到您的DropDown列表。
现在,当您从下拉菜单中选择用户时,您将拥有一个UserName,将其存储到字符串属性,如 SelectedUser 。在这种情况下,请将 SelectedUser 视为 John 。
然后使用以下查询获取有关 John 的详细信息,
It will returns the list of UserNames. Bind this to your DropDown List.
And Now, When your are selecting an user from dropdown menu, you will have a single UserName, store it to a string property like SelectedUser. In this case, consider the SelectedUser as John.
Then use the following query to get the details about John,
Select * from AllUsers Where UserName='John'
它返回如下所示的整行,
UserId | UserName | PhoneNumber | 地址 |
---|---|---|---|
User1 | John | 4567891234 | Xyz |
It returns the entire row like the following,
UserId | UserName | PhoneNumber | Address |
---|---|---|---|
User1 | John | 4567891234 | Xyz |
这篇关于显示数据库中的所有用户,如果我选择任何用户,我需要显示所选用户的所有详细信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!