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

x
?
Solved

Binding checkbox in GridView to a "Y" or "N" char(1) field in database table.

Posted on 2007-03-19
2
Medium Priority
?
4,170 Views
Last Modified: 2013-11-07
Is there a simple way to have a checkbox in a GridView bound to a column in the database table that is a CHAR(1) column with a value of "Y" or "N"? I have the GridView bound to an SqlDataSource control, but if I need to bind the GridView to a DataSet created in the code-behind, I could do that, too. The data is coming from a Stored Procedure, so I could also modify the proc to return a boolean instead of the Y/N, but I also need to do an "add" and "update" through the GridView, and so that would also mean modifying those procs to translate the boolean value from the GridView into the Y/N needed by the database table.

Any of these would be simple enough to accomplish, but I'm just wondering about how to go about binding a checkbox to a CHAR(1) column.
0
Comment
Question by:DanielBorson
[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
2 Comments
 
LVL 22

Accepted Solution

by:
DarkoLord earned 500 total points
ID: 18750429
You can use helper function to accomplish this:

C# example:

<asp:CheckBox ID="CheckBox1" Checked='<%# ((string)Eval("FieldInDatabase") == "s") %>' runat="server" />

0
 

Author Comment

by:DanielBorson
ID: 18751077
Thanks. That did the trick.
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

Prologue It is often required to host multiple websites on a single instance of IIS, mostly in development environments instead of on production servers. I am sure it is not much a preferred solution on production servers but this is at least a pos…
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.
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