473,769 Members | 3,108 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 2966
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
2705
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
2355
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
2517
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
14567
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
16429
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
3790
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
2022
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
3195
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
10211
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
9863
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
8872
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7409
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6673
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
5299
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
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3562
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.