473,378 Members | 1,344 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,378 software developers and data experts.

DataGrid & CheckBox Column

Hi.

I have a checkbox column in my datagrid like this:

<Columns>
<asp:TemplateColumn HeaderText=" ">
<ItemTemplate>
<asp:CheckBox ID='Selection'
runat="server"></asp:CheckBox>
<asp:Label ID="SelectID" Visible="False" Text='<%#
DataBinder.Eval(Container.DataItem, "CustomerID") + "_" +
DataBinder.Eval(Container.DataItem, "OrderID") %>' Runat=server />
</ItemTemplate>
</asp:TemplateColumn>

When I try to get the state of checked checkboxes, it's telling me that it's
not checked. I tried EnableViewState=true, but the result is the same.

Here is my code behind:

private void btnInclude_Click(object sender, System.EventArgs e)
{
System.Web.UI.WebControls.CheckBox oCheckBox;
string sID;

foreach (DataGridItem oItem in DataGrid1.Items)
{
oCheckBox = (System.Web.UI.WebControls.CheckBox)
oItem.FindControl("Selection");
sID = CustomerType.SelectedValue + "_" + ((Label)
oItem.FindControl("SelectID")).Text;

if (oCheckBox.Checked)
{
sID = CustomerType.SelectedValue + "_" + ((Label)
oItem.FindControl("SelectID")).Text;
int nTemp = 0;
}
}

However, the value of sID comes out correctly. Your input is appreciated.
--
Be Cool!
Jul 21 '05 #1
1 1851
It turns out that the problem is in the Page_load because I am binding to a
datagrid.

Thanks.

"thejackofall" wrote:
Hi.

I have a checkbox column in my datagrid like this:

<Columns>
<asp:TemplateColumn HeaderText=" ">
<ItemTemplate>
<asp:CheckBox ID='Selection'
runat="server"></asp:CheckBox>
<asp:Label ID="SelectID" Visible="False" Text='<%#
DataBinder.Eval(Container.DataItem, "CustomerID") + "_" +
DataBinder.Eval(Container.DataItem, "OrderID") %>' Runat=server />
</ItemTemplate>
</asp:TemplateColumn>

When I try to get the state of checked checkboxes, it's telling me that it's
not checked. I tried EnableViewState=true, but the result is the same.

Here is my code behind:

private void btnInclude_Click(object sender, System.EventArgs e)
{
System.Web.UI.WebControls.CheckBox oCheckBox;
string sID;

foreach (DataGridItem oItem in DataGrid1.Items)
{
oCheckBox = (System.Web.UI.WebControls.CheckBox)
oItem.FindControl("Selection");
sID = CustomerType.SelectedValue + "_" + ((Label)
oItem.FindControl("SelectID")).Text;

if (oCheckBox.Checked)
{
sID = CustomerType.SelectedValue + "_" + ((Label)
oItem.FindControl("SelectID")).Text;
int nTemp = 0;
}
}

However, the value of sID comes out correctly. Your input is appreciated.
--
Be Cool!

Jul 21 '05 #2

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

Similar topics

4
by: Mike | last post by:
Hi, Is there a possibility to have one of the Web Control Datagrid's column as a Calendar when editing data? Any resources on this subject? Thanks Mike
1
by: sianan | last post by:
I tried to use the following example, to add a checkbox column to a DataGrid in an ASP.NET application: http://www.codeproject.com/aspnet/datagridcheckbox.asp For some reason, I simply CAN'T get...
1
by: thejackofall | last post by:
Hi. I have a checkbox column in my datagrid like this: <Columns> <asp:TemplateColumn HeaderText=" "> <ItemTemplate> <asp:CheckBox ID='Selection' runat="server"></asp:CheckBox> <asp:Label...
1
by: thejackofall | last post by:
Hi. I have a checkbox column in my datagrid like this: <Columns> <asp:TemplateColumn HeaderText=" "> <ItemTemplate> <asp:CheckBox ID='Selection' runat="server"></asp:CheckBox> <asp:Label...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.