473,326 Members | 2,013 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

how to check/Uncheck a checkbox dynamically in a datagrid in asp.n

Hi

I have datagrid with 8 items. Out of which 2 items are checkboxes. Data is
binded dynamically to the datagrid

Based on some values from the database I have to check or uncheck the
checkbox in the datatgrid.

Does any one know how to do this?

Thx
Sileesh
Nov 18 '05 #1
4 2904
You can use an IIF statement in the ItemTemplate like this when you get the
value from the database:

Checked='<%# IIF(DataBinder.Eval(Container,
"DataItem.Boolean"),"true","false") %>'

Or, if the database already has a boolean, you ca do this:

Checked='<%# DataBinder.Eval(Container, "DataItem.Boolean") %>'

More code below.

Does this help?

Ken
Microsoft MVP [ASP.NET]

<asp:TemplateColumn HeaderText="Boolean Value">
<ItemTemplate>
<asp:CheckBox id=match runat="server" onCheckedChanged="updateStatus"
Checked='<%# DataBinder.Eval(Container, "DataItem.Boolean") %>'
AutoPostBack="True">
</asp:CheckBox>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Boolean Value">
<ItemTemplate>
<asp:CheckBox id="Checkbox1" runat="server"
onCheckedChanged="updateStatus" Checked='<%# IIF(DataBinder.Eval(Container,
"DataItem.Boolean"),"true","false") %>' AutoPostBack="True">
</asp:CheckBox>
</ItemTemplate>
</asp:TemplateColumn>

"Sileesh" <Si*****@discussions.microsoft.com> wrote in message
news:38**********************************@microsof t.com...
Hi

I have datagrid with 8 items. Out of which 2 items are checkboxes. Data is
binded dynamically to the datagrid

Based on some values from the database I have to check or uncheck the
checkbox in the datatgrid.

Does any one know how to do this?

Thx
Sileesh


Nov 18 '05 #2
Ken

Thanks for the exanple. Thanks for ur effort os explaining.
but I am working on windows form. In that i don't runat server procedures.
Can u tell how i can do with code behind in vb.net.

Rekha

"Ken Cox [Microsoft MVP]" wrote:
You can use an IIF statement in the ItemTemplate like this when you get the
value from the database:

Checked='<%# IIF(DataBinder.Eval(Container,
"DataItem.Boolean"),"true","false") %>'

Or, if the database already has a boolean, you ca do this:

Checked='<%# DataBinder.Eval(Container, "DataItem.Boolean") %>'

More code below.

Does this help?

Ken
Microsoft MVP [ASP.NET]

<asp:TemplateColumn HeaderText="Boolean Value">
<ItemTemplate>
<asp:CheckBox id=match runat="server" onCheckedChanged="updateStatus"
Checked='<%# DataBinder.Eval(Container, "DataItem.Boolean") %>'
AutoPostBack="True">
</asp:CheckBox>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Boolean Value">
<ItemTemplate>
<asp:CheckBox id="Checkbox1" runat="server"
onCheckedChanged="updateStatus" Checked='<%# IIF(DataBinder.Eval(Container,
"DataItem.Boolean"),"true","false") %>' AutoPostBack="True">
</asp:CheckBox>
</ItemTemplate>
</asp:TemplateColumn>

"Sileesh" <Si*****@discussions.microsoft.com> wrote in message
news:38**********************************@microsof t.com...
Hi

I have datagrid with 8 items. Out of which 2 items are checkboxes. Data is
binded dynamically to the datagrid

Based on some values from the database I have to check or uncheck the
checkbox in the datatgrid.

Does any one know how to do this?

Thx
Sileesh


Nov 18 '05 #3
Wrong group for Windows Forms. This is ASP.NET.
"Rekha" <Re***@discussions.microsoft.com> wrote in message
news:14**********************************@microsof t.com...
Ken

Thanks for the exanple. Thanks for ur effort os explaining.
but I am working on windows form. In that i don't runat server procedures.
Can u tell how i can do with code behind in vb.net.

Rekha


Nov 18 '05 #4
thanks ..

"Ken Cox [Microsoft MVP]" wrote:
Wrong group for Windows Forms. This is ASP.NET.
"Rekha" <Re***@discussions.microsoft.com> wrote in message
news:14**********************************@microsof t.com...
Ken

Thanks for the exanple. Thanks for ur effort os explaining.
but I am working on windows form. In that i don't runat server procedures.
Can u tell how i can do with code behind in vb.net.

Rekha


Nov 18 '05 #5

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

Similar topics

3
by: Rich | last post by:
I have a form with 2 check boxes. One of the check boxes is used to specify that the user is a "primary contact." When I check the primary contact box I want a second box for "standard contact"...
2
by: Rekha | last post by:
Hi I have datagrid with 5 items. Out of which 1 items are checkboxes. The bool column(checkbox column ) in added in datagrid. The rest of Data is binded dynamically to the datagrid Based on...
1
by: Neal | last post by:
HI all, I have an issue with check box in datagrid. I would like it to check and uncheck based on a database value of NULL or a Date Value. If there is a date value for that column then check...
7
by: Jaime Stuardo | last post by:
Hi all.. I have a DataGrid with checkboxes. In the header I have a "check all" checkbox. I'm wondering if there is an easy way to check all checkboxes using that checkbox. I could do it using...
3
by: Fao, Sean | last post by:
I have a DataGrid that I'm adding CheckBox controls to at runtime (in the code behind) and I'm not sure if I'm doing it correctly. First of all, I noticed that the MyDataGrid.Columns.Add() method...
2
by: Chris Davoli | last post by:
How do you enable a check box in the GridView. I selected Checkbox Field in the Columns of the GridView, and the check box shows up in the Grid view, but it is disabled. How do I enable it so I can...
10
by: rn5a | last post by:
All the rows in a DataGrid, including the Header, are accompanied with a CheckBox. I want that when the CheckBox in the Header is checked, then all the CheckBoxes should automatically get checked....
13
by: PhpCool | last post by:
Hi, since sometime I'm stuck in a problem where I want to check or uncheck all the checkboxes. If I'm choosing name for the checkbox array as 'chkbx_ary' then I'm able to check/uncheck all the...
1
by: Anuj | last post by:
Hi, since sometime I'm stuck in a problem where I want to check or uncheck all the checkboxes. If I'm choosing name for the checkbox array as 'chkbx_ary' then I'm able to check/uncheck all the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.