Click here to Skip to main content
15,915,042 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
ASP.NET
<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 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#
Posted
Updated 3-Feb-16 20:41pm
v3
Comments
Sinisa Hajnal 4-Feb-16 3:12am    
Google for a bit and you'll find it. There are several ways, one of the worst of them includes returning everything at once. Why would you retrieve data about 100 users if page user will only look at the details of two or three of them?

Instead, fetch IDs and names or whatever you're showing and when the user is selected, go to the database and fetch the details needed.

1 solution

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,
SQL
Select UserName from AllUsers

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,
SQL
Select * from AllUsers Where UserName='John'

It returns the entire row like the following,

UserId UserName PhoneNumber Address
User1 John 4567891234 Xyz
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900