Solved

GridView Checkbox Value Convert to T/F?

Posted on 2012-03-20
4
223 Views
Last Modified: 2012-03-22
I need to convert the standard checkbox value of true/false to T/F. I'm working on a database table with a string(1) column type. Only accepts T or F. Here's the code I have so far, still looking for more efficient way to convert.

   dr = dt.NewRow();
   dr[0] = gridView1.DataKeys[row.RowIndex]["id"].ToString();
   dr[1] = checkBox1.Checked.ToString().Replace("false", "F").Replace("true", "T");
   dt.Rows.Add(dr);

Help!
0
Comment
Question by:pointeman
[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
  • 2
4 Comments
 
LVL 7

Accepted Solution

by:
Lalit Chandra earned 500 total points
ID: 37744551
you can do

  dr[1] = checkBox1.Checked ? "T" : "F";
0
 

Author Comment

by:pointeman
ID: 37751846
Excellent!

Q. What do you call this kind of validation or string substitution called?
0
 
LVL 7

Expert Comment

by:Lalit Chandra
ID: 37751880
This is normal c sharp  code.  This is Conditioanl/Ternary Operator.
You can know more from the below link

http://msdn.microsoft.com/en-us/library/ty67wk28.aspx

Hope this link will clear your view..
0
 

Author Closing Comment

by:pointeman
ID: 37755148
thx
0

Featured Post

Technology Partners: 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

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

635 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