473,850 Members | 2,036 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

convert boolean to checkbox in Item_Bound event

ICollection CreateDataSourc e() {
dt.Columns.Add( new DataColumn("Rep ortInclude", typeof(Boolean) ));
for (int i=0; i<=10; i++) { dr = dt.NewRow(); dr[0] = 0;
dt.Rows.Add(dr) ; }

void Page_Load(Objec t sender, EventArgs e)
{ ItemsGrid.DataS ource = CreateDataSourc e();

void Item_Bound(Obje ct sender, DataGridItemEve ntArgs e)
{
// Use the ItemDataBound event to customize the DataGrid control.
// The ItemDataBound event allows you to access the data before
// the item is displayed in the control.

????? How do I convert the boolean value to a checkbox. I don't want
to see true/false, I want to see a checkbox, checked or not.

Thank you,
-Greg
May 2 '06 #1
6 2971
something like:

you might have to check for e.Item.ItemType to make sure it isn't a
header/footer...
CheckBox check = (CheckBox)
e.Item.FindCont rol("IdOfTheRun atServerCheckbo x");
check.Checked =
Convert.ToBoole an(((DataRowVie w)e.Item.DataIt em)["ReportIncl ude"]);

Karl

--
http://www.openmymind.net/
http://www.fuelindustries.com/
"hazz" <hazz@sonic_net > wrote in message
news:eF******** ******@TK2MSFTN GP04.phx.gbl...
ICollection CreateDataSourc e() {
dt.Columns.Add( new DataColumn("Rep ortInclude", typeof(Boolean) ));
for (int i=0; i<=10; i++) { dr = dt.NewRow(); dr[0] = 0;
dt.Rows.Add(dr) ; }

void Page_Load(Objec t sender, EventArgs e)
{ ItemsGrid.DataS ource = CreateDataSourc e();

void Item_Bound(Obje ct sender, DataGridItemEve ntArgs e)
{
// Use the ItemDataBound event to customize the DataGrid control.
// The ItemDataBound event allows you to access the data before
// the item is displayed in the control.

????? How do I convert the boolean value to a checkbox. I don't want
to see true/false, I want to see a checkbox, checked or not.

Thank you,
-Greg

May 2 '06 #2
Thank you so much Karl.

One follow up question having to do with the design time structure of the
checkbox column for the.FindControl ("IdOfTheRunatS erverCheckbox") ; Where
does IdOfTheRunatSer verCheckbox go within the <asp:> </asp?> as listed here
from my aspx page?

<asp:DataGrid id="ItemsGrid" runat="server"
OnItemDataBound ="Item_Bound ">
<HeaderStyle BackColor="#00a aaa"> </HeaderStyle>
<FooterStyle BackColor="#00a aaa"></FooterStyle>
</asp:DataGrid>

Thank you,
Greg

"Karl Seguin [MVP]" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME
net> wrote in message news:u0******** ******@TK2MSFTN GP04.phx.gbl...
something like:

you might have to check for e.Item.ItemType to make sure it isn't a
header/footer...
CheckBox check = (CheckBox)
e.Item.FindCont rol("IdOfTheRun atServerCheckbo x");
check.Checked =
Convert.ToBoole an(((DataRowVie w)e.Item.DataIt em)["ReportIncl ude"]);

Karl

--
http://www.openmymind.net/
http://www.fuelindustries.com/
"hazz" <hazz@sonic_net > wrote in message
news:eF******** ******@TK2MSFTN GP04.phx.gbl...
ICollection CreateDataSourc e() {
dt.Columns.Add( new DataColumn("Rep ortInclude", typeof(Boolean) ));
for (int i=0; i<=10; i++) { dr = dt.NewRow(); dr[0] = 0;
dt.Rows.Add(dr) ; }

void Page_Load(Objec t sender, EventArgs e)
{ ItemsGrid.DataS ource = CreateDataSourc e();

void Item_Bound(Obje ct sender, DataGridItemEve ntArgs e)
{
// Use the ItemDataBound event to customize the DataGrid control.
// The ItemDataBound event allows you to access the data before
// the item is displayed in the control.

????? How do I convert the boolean value to a checkbox. I don't want
to see true/false, I want to see a checkbox, checked or not.

Thank you,
-Greg


May 2 '06 #3
Sorry, I zoned out the entire datagrid thing :)

You'll need to turn off autogeneratecol umns and output it yourself:

<asp:DataGrid ID="grid" runat="Server" OnItemDataBound ="Item_Bound ">
<Columns>
<asp:TemplateCo lumn>
<ItemTemplate >
<asp:CheckBox ID="myCheckbox " runat="Server" />
</ItemTemplate>
</asp:TemplateCol umn>
</Columns>
</asp:DataGrid>
Karl
--
http://www.openmymind.net/
http://www.fuelindustries.com/
"hazz" <hazz@sonic_net > wrote in message
news:ev******** ******@TK2MSFTN GP03.phx.gbl...
Thank you so much Karl.

One follow up question having to do with the design time structure of the
checkbox column for the.FindControl ("IdOfTheRunatS erverCheckbox") ; Where
does IdOfTheRunatSer verCheckbox go within the <asp:> </asp?> as listed
here from my aspx page?

<asp:DataGrid id="ItemsGrid" runat="server"
OnItemDataBound ="Item_Bound ">
<HeaderStyle BackColor="#00a aaa"> </HeaderStyle>
<FooterStyle BackColor="#00a aaa"></FooterStyle>
</asp:DataGrid>

Thank you,
Greg

"Karl Seguin [MVP]" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME
net> wrote in message news:u0******** ******@TK2MSFTN GP04.phx.gbl...
something like:

you might have to check for e.Item.ItemType to make sure it isn't a
header/footer...
CheckBox check = (CheckBox)
e.Item.FindCont rol("IdOfTheRun atServerCheckbo x");
check.Checked =
Convert.ToBoole an(((DataRowVie w)e.Item.DataIt em)["ReportIncl ude"]);

Karl

--
http://www.openmymind.net/
http://www.fuelindustries.com/
"hazz" <hazz@sonic_net > wrote in message
news:eF******** ******@TK2MSFTN GP04.phx.gbl...
ICollection CreateDataSourc e() {
dt.Columns.Add( new DataColumn("Rep ortInclude", typeof(Boolean) ));
for (int i=0; i<=10; i++) { dr = dt.NewRow(); dr[0] = 0;
dt.Rows.Add(dr) ; }

void Page_Load(Objec t sender, EventArgs e)
{ ItemsGrid.DataS ource = CreateDataSourc e();

void Item_Bound(Obje ct sender, DataGridItemEve ntArgs e)
{
// Use the ItemDataBound event to customize the DataGrid control.
// The ItemDataBound event allows you to access the data before
// the item is displayed in the control.

????? How do I convert the boolean value to a checkbox. I don't
want to see true/false, I want to see a checkbox, checked or not.

Thank you,
-Greg



May 2 '06 #4
When I add the following to the gridview
<Columns>
<asp:TemplateCo lumn>
<EditItemTempla te>
<asp:CheckBox ID="CheckBox1"
Text="Taxable"
runat="server"/>
</EditItemTemplat e>
</asp:TemplateCol umn>
</Columns>

CheckBox check = (CheckBox)e.Ite m.FindControl(" CheckBox1") returns a null.
"hazz" <hazz@sonic_net > wrote in message
news:ev******** ******@TK2MSFTN GP03.phx.gbl...
Thank you so much Karl.

One follow up question having to do with the design time structure of the
checkbox column for the.FindControl ("IdOfTheRunatS erverCheckbox") ; Where
does IdOfTheRunatSer verCheckbox go within the <asp:> </asp?> as listed
here from my aspx page?

<asp:DataGrid id="ItemsGrid" runat="server"
OnItemDataBound ="Item_Bound ">
<HeaderStyle BackColor="#00a aaa"> </HeaderStyle>
<FooterStyle BackColor="#00a aaa"></FooterStyle>
</asp:DataGrid>

Thank you,
Greg

"Karl Seguin [MVP]" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME
net> wrote in message news:u0******** ******@TK2MSFTN GP04.phx.gbl...
something like:

you might have to check for e.Item.ItemType to make sure it isn't a
header/footer...
CheckBox check = (CheckBox)
e.Item.FindCont rol("IdOfTheRun atServerCheckbo x");
check.Checked =
Convert.ToBoole an(((DataRowVie w)e.Item.DataIt em)["ReportIncl ude"]);

Karl

--
http://www.openmymind.net/
http://www.fuelindustries.com/
"hazz" <hazz@sonic_net > wrote in message
news:eF******** ******@TK2MSFTN GP04.phx.gbl...
ICollection CreateDataSourc e() {
dt.Columns.Add( new DataColumn("Rep ortInclude", typeof(Boolean) ));
for (int i=0; i<=10; i++) { dr = dt.NewRow(); dr[0] = 0;
dt.Rows.Add(dr) ; }

void Page_Load(Objec t sender, EventArgs e)
{ ItemsGrid.DataS ource = CreateDataSourc e();

void Item_Bound(Obje ct sender, DataGridItemEve ntArgs e)
{
// Use the ItemDataBound event to customize the DataGrid control.
// The ItemDataBound event allows you to access the data before
// the item is displayed in the control.

????? How do I convert the boolean value to a checkbox. I don't
want to see true/false, I want to see a checkbox, checked or not.

Thank you,
-Greg



May 2 '06 #5
Thanks Karl, I'm getting closer !! I have checkable checkboxes. -Greg

"Karl Seguin [MVP]" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME
net> wrote in message news:OT******** ******@TK2MSFTN GP03.phx.gbl...
Sorry, I zoned out the entire datagrid thing :)

You'll need to turn off autogeneratecol umns and output it yourself:

<asp:DataGrid ID="grid" runat="Server" OnItemDataBound ="Item_Bound ">
<Columns>
<asp:TemplateCo lumn>
<ItemTemplate >
<asp:CheckBox ID="myCheckbox " runat="Server" />
</ItemTemplate>
</asp:TemplateCol umn>
</Columns>
</asp:DataGrid>
Karl
--
http://www.openmymind.net/
http://www.fuelindustries.com/
"hazz" <hazz@sonic_net > wrote in message
news:ev******** ******@TK2MSFTN GP03.phx.gbl...
Thank you so much Karl.

One follow up question having to do with the design time structure of the
checkbox column for the.FindControl ("IdOfTheRunatS erverCheckbox") ; Where
does IdOfTheRunatSer verCheckbox go within the <asp:> </asp?> as listed
here from my aspx page?

<asp:DataGrid id="ItemsGrid" runat="server"
OnItemDataBound ="Item_Bound ">
<HeaderStyle BackColor="#00a aaa"> </HeaderStyle>
<FooterStyle BackColor="#00a aaa"></FooterStyle>
</asp:DataGrid>

Thank you,
Greg

"Karl Seguin [MVP]" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME
net> wrote in message news:u0******** ******@TK2MSFTN GP04.phx.gbl...
something like:

you might have to check for e.Item.ItemType to make sure it isn't a
header/footer...
CheckBox check = (CheckBox)
e.Item.FindCont rol("IdOfTheRun atServerCheckbo x");
check.Checked =
Convert.ToBoole an(((DataRowVie w)e.Item.DataIt em)["ReportIncl ude"]);

Karl

--
http://www.openmymind.net/
http://www.fuelindustries.com/
"hazz" <hazz@sonic_net > wrote in message
news:eF******** ******@TK2MSFTN GP04.phx.gbl...
ICollection CreateDataSourc e() {
dt.Columns.Add( new DataColumn("Rep ortInclude", typeof(Boolean) ));
for (int i=0; i<=10; i++) { dr = dt.NewRow(); dr[0] = 0;
dt.Rows.Add(dr) ; }

void Page_Load(Objec t sender, EventArgs e)
{ ItemsGrid.DataS ource = CreateDataSourc e();

void Item_Bound(Obje ct sender, DataGridItemEve ntArgs e)
{
// Use the ItemDataBound event to customize the DataGrid control.
// The ItemDataBound event allows you to access the data before
// the item is displayed in the control.

????? How do I convert the boolean value to a checkbox. I don't
want to see true/false, I want to see a checkbox, checked or not.

Thank you,
-Greg



May 2 '06 #6
I kinda hinted at that first...but it wasn't clear, sorry..
If (e.Item.ItemTyp e == ListItemType.It em || e.Item.ItemType ==
ListItemType.Al ternatingItem)
{
///do stuff
}

there won't be a "CheckBox1" when ItemType is Header or Footer or etc...
Karl

--
http://www.openmymind.net/
http://www.fuelindustries.com/
"hazz" <hazz@sonic_net > wrote in message
news:%2******** ********@TK2MSF TNGP05.phx.gbl. ..
When I add the following to the gridview
<Columns>
<asp:TemplateCo lumn>
<EditItemTempla te>
<asp:CheckBox ID="CheckBox1"
Text="Taxable"
runat="server"/>
</EditItemTemplat e>
</asp:TemplateCol umn>
</Columns>

CheckBox check = (CheckBox)e.Ite m.FindControl(" CheckBox1") returns a
null.
"hazz" <hazz@sonic_net > wrote in message
news:ev******** ******@TK2MSFTN GP03.phx.gbl...
Thank you so much Karl.

One follow up question having to do with the design time structure of the
checkbox column for the.FindControl ("IdOfTheRunatS erverCheckbox") ; Where
does IdOfTheRunatSer verCheckbox go within the <asp:> </asp?> as listed
here from my aspx page?

<asp:DataGrid id="ItemsGrid" runat="server"
OnItemDataBound ="Item_Bound ">
<HeaderStyle BackColor="#00a aaa"> </HeaderStyle>
<FooterStyle BackColor="#00a aaa"></FooterStyle>
</asp:DataGrid>

Thank you,
Greg

"Karl Seguin [MVP]" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME
net> wrote in message news:u0******** ******@TK2MSFTN GP04.phx.gbl...
something like:

you might have to check for e.Item.ItemType to make sure it isn't a
header/footer...
CheckBox check = (CheckBox)
e.Item.FindCont rol("IdOfTheRun atServerCheckbo x");
check.Checked =
Convert.ToBoole an(((DataRowVie w)e.Item.DataIt em)["ReportIncl ude"]);

Karl

--
http://www.openmymind.net/
http://www.fuelindustries.com/
"hazz" <hazz@sonic_net > wrote in message
news:eF******** ******@TK2MSFTN GP04.phx.gbl...
ICollection CreateDataSourc e() {
dt.Columns.Add( new DataColumn("Rep ortInclude", typeof(Boolean) ));
for (int i=0; i<=10; i++) { dr = dt.NewRow(); dr[0] = 0;
dt.Rows.Add(dr) ; }

void Page_Load(Objec t sender, EventArgs e)
{ ItemsGrid.DataS ource = CreateDataSourc e();

void Item_Bound(Obje ct sender, DataGridItemEve ntArgs e)
{
// Use the ItemDataBound event to customize the DataGrid control.
// The ItemDataBound event allows you to access the data before
// the item is displayed in the control.

????? How do I convert the boolean value to a checkbox. I don't
want to see true/false, I want to see a checkbox, checked or not.

Thank you,
-Greg



May 2 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2709
by: ET | last post by:
I don't know whats the problem, but after I added functions to first verify, then relink linked tables if not found, now I can't convert that database to MDE format. I can split the database, but can't convert part of the database with forms, reports, queries to MDE format. Can somebody advice on this? References, in the order, from the top:
2
2359
by: Raj | last post by:
Hi, When we are sorting the DataGrid Boolean column the grid is becoming redcross. I have my own PPMIPDataGridBoolColumn class inherited from System.Windows.Forms.DataGridBoolColumn. In this inherited class I have one DataGridValueChangedEventHandler event handler. I am overriding Edit() to know the current state of the cell. I am overriding Paint() to know the if the user has been editing the cell. I am also overriding the Commit() to
4
2523
by: Patrick.O.Ige | last post by:
I'm DataBinding a CheckBoxList and i want to get the checkboxes selected when the page is loaded depending on a Boolean value from the Database.. chkDebtor.DataSource = objDR chkDebtor.DataValueField = "checked" -- this is a column in the table that returns 1 or 0 chkDebtor.DataTextField = "DebtorCode" chkDebtor.DataBind() Dim i As Integer = 0 While i < chkDebtor.Items.Count
6
14571
by: Tim Cartwright | last post by:
I have a page that has the login control on it, nothing else. This page inherits from a master page, neither page has any code in it. This page works perfectly when running on the WebDev debug web server. I am able to log in. However after publishing the page to my local IIS, it results in the below error. This error is occurring on the Visual Studio.Net 2k5 release version, but did not occur on the beta 2, same code. A point of interest, is...
0
951
by: dfetrow410 | last post by:
<asp:Content ID="content2" ContentPlaceHolderID="leadercontent" runat="Server"> <asp:DataList ID="DataList2" runat="server" OnItemDataBound = "Item_Bound" CellPadding="1" CellSpacing="1" RepeatColumns="1" RepeatDirection="vertical" DataSourceID="SqlDataSource1" Width="199px"
10
16439
by: dba123 | last post by:
Why am I getting this error for Budget? Error: An exception of type 'System.FormatException' occurred in mscorlib.dll but was not handled in user code Additional information: String was not recognized as a valid Boolean. Public Sub UpdateCustomer_DashboardGraphs(ByVal sender As Object, ByVal e As System.EventArgs)
5
3796
by: Learner | last post by:
Hello, Here is the code snippet I got strucked at. I am unable to convert the below line of code to its equavalent vb.net code. could some one please help me with this? static public List<RoleData> GetRoles() { return GetRoles(null, false); }
2
2027
by: Carlos Aguayo | last post by:
Hi, Is there a better way to do this? The problem that I have is that x can be "true" or "false" (as type string), or true or false (as boolean type). I'm doing comparisons like... if (eval(x) == true){ // do something... }
2
3198
by: joecosmides | last post by:
I have a microsoft access front end and backend database for multi- user use. I have the back end located on a server that also is an IIS webserver. I've created a few ASP pages that pull customer lists down so far and it works great. I am trying to edit some of that data and noticed that a checkbox on the webpage uses ON/OFF instead of True/ False like MS Access uses. My problem is trying to get the checkbox to be checked if the data in...
0
9895
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
0
11011
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10670
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10725
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10352
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7072
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5735
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5931
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4142
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.