Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Reading boolean from DB

Posted on 2016-08-15
5
Medium Priority
?
55 Views
Last Modified: 2016-08-17
With EEs' help, this is the code in ASP.NET, it is a boolean type in sql
                                           <asp:DropDownList ID="Active" runat="server">                           
                                                <asp:ListItem value="">Select</asp:ListItem>
                                                <asp:ListItem value="1">Yes</asp:ListItem>			        
                                                <asp:ListItem value="0">No</asp:ListItem>			
                                           </asp:DropDownList>  

Open in new window


I have no problem saving selected value into sql, but I am not sure how to read it back to the frontend.

I have tried
                if (Active.Text == "True")
                    Active.Text = "1";
                else
                {
                    Active.Text = "0";
                }

Open in new window


and

Active.Text = reader["Active"].ToString();

Open in new window


But the dropdown list is not picking up the value....Can EEs give me some help?  thanks
0
Comment
Question by:mcrmg
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 53

Accepted Solution

by:
Ryan Chong earned 2000 total points
ID: 41756602
>>but I am not sure how to read it back to the frontend
you need to set its SelectedIndex property

you can adapt and cstomize the 2nd way in this article:
Programmatically select an item in asp.net dropdownlist by text
http://techbrij.com/select-item-aspdotnet-dropdownlist-programmatically
0
 

Assisted Solution

by:mcrmg
mcrmg earned 0 total points
ID: 41756756
thank you
0
 
LVL 19

Expert Comment

by:Manoj Patil
ID: 41757443
You need to do this
if (Active.Text == "True")
     Active.SelectedIndex=1;
else
    Active.SelectedIndex=2;

Open in new window

0
 

Author Closing Comment

by:mcrmg
ID: 41759203
0
 

Author Comment

by:mcrmg
ID: 41759204
thank you
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question