数据网格中的CheckBox控件 [英] CheckBox control in a datagrid

查看:93
本文介绍了数据网格中的CheckBox控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我有一个数据网格,可以从查询中获取一些信息。我需要

在每一行都有一个复选框,这样用户就可以选择他想要的行来重新打印。是否可以在数据网格中使用复选框控件?现在我

有一个Select列,但问题是用户需要选择更多

而不是一条记录并将它们全部发送到打印,而不是一个一个地像

现在带有Select列。


另一个问题,是否有可能在

中使用不同颜色的行格?例如,我有一个名为Inv的列。这带来了库存

库存,每次他们在这个字段中有0,他们希望看到

颜色为红色的行,这样他们就可以识别出他们的库存不合格了该项目,以及超过0的

项目仍以黑色显示。这可能吗?


提前致谢

jennyfer

Hello, I have a datagrid that brings some information from a query. I need
to have a checkbox in each row so the user can select the rows he wants to
reprint. Is it possible to have a checkbox control in a datagrid? Now I
have a Select column but the problem is that the user needs to select more
than one record and send them all to print, instead of being one by one like
is now with the Select column.

Another question, is it possible to have a row with diferent color in a
grid? For example I have a column called Inv. that brings the inventory
stock and everytime they have 0 in this field they want to see the row in
color red so they can identify they''re out of ctock for that item, and the
items that have more than 0 still show in color black. Is this possible?

Thanks in advance
jennyfer

推荐答案

Jennyfer :

请查看: http:// openmymind。 net / databinding / index.html 应该

至少回答你的第二个问题。基本上你可以使用

OnItemDataBound,获取数据绑定,如果它是某些东西(比如

0),你可以控制改变UI元素(喜欢红色背景)。


至于你的第一个问题。您可以在每一行中使用CheckBox控件,并在底部(在页脚模板中)添加一个打印按钮。单击

按钮时,循环遍历网格的每一行(对于每一行,作为Grid.Items中的
DataGridItem)找到复选框:


dim chk作为Checkbox =(CheckBox)row.FindControls(" checkBoxId")

如果不是chk什么都不是,而且chk.Checked = true则

''此项目已经过检查,可能会将它们全部添加到arraylists,然后循环

通过这些并打印每个相应的记录

结束如果

教程也应该帮助你:)


Karl


-

我的ASP。网络教程
http://www.openmymind.net/

" Jennyfer J Barco" < PD ***** @ nospam.wdsinc.com>在消息中写道

新闻:OI ************* @ TK2MSFTNGP14.phx.gbl ...
Jennyfer:
Take a look at: http://openmymind.net/databinding/index.html it should
atleast answer your second question. Basically you can use the
OnItemDataBound even, get the data being bound and if it''s something (like a
0) give you the control to change UI elements (like a red background).

As for your first question. You can use a CheckBox control in each row, and
add a ''Print'' button at the bottom (in the footer template). When the
button is clicked, you loop through each row of the grid (for each row as
DataGridItem in Grid.Items) find the checkbox:

dim chk as Checkbox = (CheckBox)row.FindControls("checkBoxId")
if not chk is nothing andalso chk.Checked = true then
''this item is checked, maybe add them all to arraylists, then loop
through those and print each corresponding record
end if
the tutorial should help you with that as well :)

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Jennyfer J Barco" <pd*****@nospam.wdsinc.com> wrote in message
news:OI*************@TK2MSFTNGP14.phx.gbl...
你好,我有一个数据网格这会从查询中获取一些信息。我需要
在每一行都有一个复选框,以便用户可以选择他想要重新打印的行。是否可以在数据网格中使用复选框控件?现在我有一个Select列,但问题是用户需要选择更多
而不是一个记录并将它们全部发送到打印,而不是一个一个
就像现在一样选择列。

另一个问题是,是否可以在
网格中使用不同颜色的行?例如,我有一个名为Inv的列。它带来了库存库存,每次他们在这个领域都有0,他们希望看到红色的行是红色的,这样他们就可以识别出他们不在那个项目的ctock,并且
大于0的项目仍以黑色显示。这可能吗?

提前致谢
jennyfer
Hello, I have a datagrid that brings some information from a query. I need
to have a checkbox in each row so the user can select the rows he wants to
reprint. Is it possible to have a checkbox control in a datagrid? Now I
have a Select column but the problem is that the user needs to select more
than one record and send them all to print, instead of being one by one like is now with the Select column.

Another question, is it possible to have a row with diferent color in a
grid? For example I have a column called Inv. that brings the inventory
stock and everytime they have 0 in this field they want to see the row in
color red so they can identify they''re out of ctock for that item, and the
items that have more than 0 still show in color black. Is this possible?

Thanks in advance
jennyfer



Jennyfer:

请查看: http://openmymind.net/databinding/index。 html 它应该

至少回答你的第二个问题。基本上你可以使用

OnItemDataBound,获取数据绑定,如果它是某些东西(比如

0),你可以控制改变UI元素(喜欢红色背景)。


至于你的第一个问题。您可以在每一行中使用CheckBox控件,并在底部(在页脚模板中)添加一个打印按钮。单击

按钮时,循环遍历网格的每一行(对于每一行,作为Grid.Items中的
DataGridItem)找到复选框:


dim chk作为Checkbox =(CheckBox)row.FindControls(" checkBoxId")

如果不是chk什么都不是,而且chk.Checked = true则

''此项目已经过检查,可能会将它们全部添加到arraylists,然后循环

通过这些并打印每个相应的记录

结束如果

教程也应该帮助你:)


Karl


-

我的ASP。网络教程
http://www.openmymind.net/

" Jennyfer J Barco" < PD ***** @ nospam.wdsinc.com>在消息中写道

新闻:OI ************* @ TK2MSFTNGP14.phx.gbl ...
Jennyfer:
Take a look at: http://openmymind.net/databinding/index.html it should
atleast answer your second question. Basically you can use the
OnItemDataBound even, get the data being bound and if it''s something (like a
0) give you the control to change UI elements (like a red background).

As for your first question. You can use a CheckBox control in each row, and
add a ''Print'' button at the bottom (in the footer template). When the
button is clicked, you loop through each row of the grid (for each row as
DataGridItem in Grid.Items) find the checkbox:

dim chk as Checkbox = (CheckBox)row.FindControls("checkBoxId")
if not chk is nothing andalso chk.Checked = true then
''this item is checked, maybe add them all to arraylists, then loop
through those and print each corresponding record
end if
the tutorial should help you with that as well :)

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Jennyfer J Barco" <pd*****@nospam.wdsinc.com> wrote in message
news:OI*************@TK2MSFTNGP14.phx.gbl...
你好,我有一个数据网格这会从查询中获取一些信息。我需要
在每一行都有一个复选框,以便用户可以选择他想要重新打印的行。是否可以在数据网格中使用复选框控件?现在我有一个Select列,但问题是用户需要选择更多
而不是一个记录并将它们全部发送到打印,而不是一个一个
就像现在一样选择列。

另一个问题是,是否可以在
网格中使用不同颜色的行?例如,我有一个名为Inv的列。它带来了库存库存,每次他们在这个领域都有0,他们希望看到红色的行是红色的,这样他们就可以识别出他们不在那个项目的ctock,并且
大于0的项目仍以黑色显示。这可能吗?

提前致谢
jennyfer
Hello, I have a datagrid that brings some information from a query. I need
to have a checkbox in each row so the user can select the rows he wants to
reprint. Is it possible to have a checkbox control in a datagrid? Now I
have a Select column but the problem is that the user needs to select more
than one record and send them all to print, instead of being one by one like is now with the Select column.

Another question, is it possible to have a row with diferent color in a
grid? For example I have a column called Inv. that brings the inventory
stock and everytime they have 0 in this field they want to see the row in
color red so they can identify they''re out of ctock for that item, and the
items that have more than 0 still show in color black. Is this possible?

Thanks in advance
jennyfer



非常感谢,第一部分工作得很好,但在

a datagrid中创建一个复选框是个问题。在网格的属性中,我找不到一种方法

将列定义为复选框类型。


非常感谢


" Karl Seguin" < karl REMOVE @ REMOVE openmymind REMOVEMETOO。 ANDME net>

在消息新闻中写道:up ************** @ TK2MSFTNGP10.phx.gbl ...
Thanks so much, the first part worked perfectly, but creating a checkbox in
a datagrid is the problem. In the properties of the grid I can''t find a way
to define the column as a checkbox type.

Thanks so much

"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:up**************@TK2MSFTNGP10.phx.gbl...
Jennyfer:
请看一下: http://openmymind.net/databinding/index .html 它应该至少回答你的第二个问题。基本上你甚至可以使用OnItemDataBound,获取绑定的数据,如果它是某些东西(比如
a 0),你可以控制改变UI元素(比如红色背景)。

至于你的第一个问题。您可以在每行中使用CheckBox控件
并在底部添加打印按钮(在页脚模板中)。单击
按钮时,循环遍历网格的每一行(对于Grid.Items中的DataGridItem的每一行)找到复选框:

dim chk as Checkbox = (CheckBox)row.FindControls(" checkBoxId")
如果不是chk什么也没有chso.Checked = true那么
''这个项目被选中,也许将它们全部添加到arraylists,然后循环结束如果

教程也应该帮助你这个:)

Karl
-
我的ASP.Net教程
http://www.openmymind .net /

" Jennyfer J Barco" < PD ***** @ nospam.wdsinc.com>在消息中写道
新闻:OI ************* @ TK2MSFTNGP14.phx.gbl ...
Jennyfer:
Take a look at: http://openmymind.net/databinding/index.html it should
atleast answer your second question. Basically you can use the
OnItemDataBound even, get the data being bound and if it''s something (like a 0) give you the control to change UI elements (like a red background).

As for your first question. You can use a CheckBox control in each row, and add a ''Print'' button at the bottom (in the footer template). When the
button is clicked, you loop through each row of the grid (for each row as
DataGridItem in Grid.Items) find the checkbox:

dim chk as Checkbox = (CheckBox)row.FindControls("checkBoxId")
if not chk is nothing andalso chk.Checked = true then
''this item is checked, maybe add them all to arraylists, then loop
through those and print each corresponding record
end if
the tutorial should help you with that as well :)

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Jennyfer J Barco" <pd*****@nospam.wdsinc.com> wrote in message
news:OI*************@TK2MSFTNGP14.phx.gbl...
你好,我有一个数据网格带来了一些信息来自查询。我
需要在每一行都有一个复选框,以便用户可以选择他想要重新打印的行
。是否可以在数据网格中使用复选框控件?现在我有一个Select列,但问题是用户需要选择
多个记录并将它们全部发送到打印,而不是一个一个
Hello, I have a datagrid that brings some information from a query. I need to have a checkbox in each row so the user can select the rows he wants to reprint. Is it possible to have a checkbox control in a datagrid? Now I
have a Select column but the problem is that the user needs to select more than one record and send them all to print, instead of being one by one


现在带有Select列。

另一个问题是,
网格中是否有可能有不同颜色的行?例如,我有一个名为Inv的列。它带来了库存
库存,每次他们在这个字段中有0,他们希望看到红色的行
,这样他们就可以识别出他们不属于该项目的ctock,并且
超过0的项目仍以黑色显示。这可能吗?

提前致谢
jennyfer
is now with the Select column.

Another question, is it possible to have a row with diferent color in a
grid? For example I have a column called Inv. that brings the inventory
stock and everytime they have 0 in this field they want to see the row in color red so they can identify they''re out of ctock for that item, and the items that have more than 0 still show in color black. Is this possible?

Thanks in advance
jennyfer




这篇关于数据网格中的CheckBox控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆