Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

GridView Checkbox Value Convert to T/F?

Posted on 2012-03-20
4
Medium Priority
?
229 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 2000 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

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Question has a verified solution.

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

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

722 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