Solved

GridView Checkbox Value Convert to T/F?

Posted on 2012-03-20
4
206 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

863 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now