DataTable _dt = new DataTable(); _dt.Columns.Add("col1", typeof(string)); // YES/NO _dt.Columns.Add("col2", typeof(string)); // Y/N _dt.Columns.Add("col3", typeof(bool)); // true/false _dt.Columns.Add("col4", typeof(int)); // 0/1 DataRow _dr = _dt.NewRow(); _dr["col1"] = "YES"; _dr["col2"] = "Y"; _dr["col3"] = true; _dr["col4"] = 1; _dt.Rows.Add(_dr); if (base.GetBool(_dt.Rows[0]["col1"]) == true) Response.Write("col1 is true."); else Response.Write("col1 is false."); if (base.GetBool(_dt.Rows[0]["col2"]) == true) Response.Write("col2 is true."); else Response.Write("col2 is false."); if (base.GetBool(_dt.Rows[0]["col3"]) == true) Response.Write("col3 is true."); else Response.Write("col3 is false."); if (base.GetBool(_dt.Rows[0]["col4"]) == true) Response.Write("col4 is true."); else Response.Write("col4 is false.");
string _str01 = "yES"; string _str02 = "y"; string _str03 = "true"; int _int04 = 1; if (base.GetBool(_str01) == true) Response.Write("_str01 is true."); else Response.Write("_str01 is false."); if (base.GetBool(_str02) == true) Response.Write("_str02 is true."); else Response.Write("_str02 is false."); if (base.GetBool(_str03) == true) Response.Write("_str03 is true."); else Response.Write("_str03 is false."); if (base.GetBool(_int04) == true) Response.Write("_int04 is true."); else Response.Write("_int04 is false.");
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="GetBool.aspx.cs" Inherits="BANANA.Web.Framework.Test.jmson.GetBool" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>GetBool</title> </head> <body> <form id="form1" runat="server"> <div> <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false"> <Columns> <asp:TemplateField HeaderText="O/X"> <ItemTemplate> <asp:CheckBox runat="server" Checked='<%# base.GetBool(Eval("CHK")) %>' /> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView> </div> </form> </body> </html>
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; namespace BANANA.Web.Framework.Test.jmson { public partial class GetBool : BANANA.Web.BasePage { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { DataTable _dt = new DataTable(); _dt.Columns.Add("CHK", typeof(string)); // YES/NO DataRow _dr = _dt.NewRow(); _dr["CHK"] = "YES"; _dt.Rows.Add(_dr); _dr = _dt.NewRow(); _dr["CHK"] = "NO"; _dt.Rows.Add(_dr); _dr = _dt.NewRow(); _dr["CHK"] = "1"; _dt.Rows.Add(_dr); GridView1.DataSource = _dt; GridView1.DataBind(); } } } }
/// <summary> /// Bool 값을 반환 /// </summary> /// <param name="_objVal">오브젝트 데이터</param> /// <returns>true 혹은 false를 반환</returns> public bool GetBool(object _objVal) /// <summary> /// Bool 값을 반환 /// </summary> /// <param name="_intVal">숫자 데이터(0/1)</param> /// <returns>true 혹은 false를 반환</returns> public bool GetBool(int _intVal) /// <summary> /// Bool 값을 반환 /// </summary> /// <param name="_strVal">문자열 데이터</param> /// <returns>true 혹은 false를 반환</returns> public bool GetBool(string _strVal)