Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

GridView Checkbox Value Convert to T/F?

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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …

877 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