By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,627 Members | 1,188 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,627 IT Pros & Developers. It's quick & easy.

Accessing checkbox properties in a repeater control

P: n/a
I have a repeater control that contains a HeaderTemplate and an ItemTemplate.
Each item contains a checkbox with an ID of chkReconciled, and the header
contains a single checkbox with an ID of chkAll. I simply want to have
chkAll be checked if every item in the repeater has its checkbox checked. In
the code behind page, I can access the checked property of chkReconciled by
doing the following:

Dim CurrentCheckBox As CheckBox
CurrentCheckBox = rptDeposits.Items(I).FindControl("chkReconciled")

Then I can check if CurrentCheckBox.checked is true. That works fine.
However, I haven't been able to set the checked property for chkAll. Since
it isn't part of the items, I have been trying the following:

Dim CheckAll As CheckBox
CheckAll = rptDeposits.FindControl("chkAll")
CheckAll.Checked = True

However, when I try to set the checked property, I get an exception saying,
"Object reference not set to an instance of an object." I've experimented
with a dozen different ways of setting the checked property of CheckAll, to
no avail. Can anyone set me on the right path?! I'm pasting the ASPX code
for the repeater below.

Thanks!
Keith

<%@ OutputCache Location="None" Duration="1" VaryByParam="None" %>
<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="Bank_recon_deposit.aspx.vb"
Inherits="IAMVFO_DEV.Bank_recon_deposit"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>Bank_recon_deposit</title>
<META http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta content="Microsoft Visual Studio.NET 7.0" name="GENERATOR">
<meta content="Visual Basic 7.0" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
<LINK href="Styles.css" type="text/css" rel="stylesheet">
</HEAD>
<BODY onresize="return Height();"
onload="setTimeout('SessionTimeout()',1080000); return Height();"
class="background">
<!--<p class="sectionHeader">Bank Reconciliation</p>-->
<form id="frmBankReconDep" method="post" runat="server">
<TABLE id="Table1" cellSpacing="0" cellPadding="0" width="100%" border="0">
<TR>
<TD class="Report_HeaderColor" style="FONT-WEIGHT: bold; FONT-SIZE:
12pt">Bank
Reconciliation
<asp:button id="btnBack" runat="server" Text="<
Back"></asp:button> <asp:button id="btnCancel" Text="Cancel and Lose Changes"
runat="server" Width="146"></asp:button>
<asp:button id="btnSave" Text="Save and Finish Later" runat="server"
Width="146px"></asp:button>
<asp:button id="btnNext" runat="server" text="Next >"
DESIGNTIMEDRAGDROP="65"></asp:button></TD>
</TR>
</TABLE>
<table cellSpacing="1" cellPadding="3" style="FONT-SIZE: 11pt; WIDTH:
100%">
<tr>
<TD class="Report_HeaderColor" align="middle">
<asp:Button id="btnCleared" runat="server" Text="Total Cleared
Deposits" Width="141px"></asp:Button></TD>
<td class="Report_HeaderColor" style="WIDTH: 175px">
<asp:Label id="lblAmount" runat="server"
Font-Size="11pt"></asp:Label></td>
<td rowSpan="2" class="Report_HeaderColor" style="FONT-SIZE: 11pt">
Please check-off the deposits that have cleared the bank, as listed on
your
bank statement.</td>
</tr>
</table>
<asp:repeater id="rptDeposits" runat="server">
<HeaderTemplate>
<div id="divTransHeader" style="VISIBILITY: hidden">
<table id="tblTransHeader" border="0" cellspacing="0"
class="HeaderTable">
<colgroup class="ShadeColHeaderDark">
<col id="colHeader1" align="center">
<col id="colHeader2" align="center">
<col id="colHeader3" align="center">
<col id="colHeader4" align="center">
<col id="colHeader5" align="center">
<col id="colHeader6" align="center">
<col id="colHeader7" align="center">
<col width="*">
</colgroup>
<tr class="TableHeaders">
<td id="tblTransHeader1_0">
<asp:label text="R/C" id="lblReconciled"
Runat="server"></asp:label></td>
<td id="tblTransHeader1_1">
<asp:LinkButton id="lnkSortDate" CausesValidation="false"
OnCommand="SortData" CommandArgument="transdate" text="Date" Runat="server"
ForeColor="#000000"></asp:LinkButton></td>
<td id="tblTransHeader1_2">
<asp:LinkButton id="lnkSortNumber" CausesValidation="false"
OnCommand="SortData" CommandArgument="depositID" text="Number" Runat="server"
ForeColor="#000000"></asp:LinkButton></td>
<td id="tblTransHeader1_3" colspan="2">
<asp:LinkButton id="lnkSortDesc" CausesValidation="false"
OnCommand="SortData" CommandArgument="TransDesc" text="Description"
Runat="server" ForeColor="#000000"></asp:LinkButton></td>
<td id="tblTransHeader1_4">
<asp:LinkButton id="lnkSortPayType" CausesValidation="false"
OnCommand="SortData" CommandArgument="paymenttype" text="Payment Type"
Runat="server" ForeColor="#000000"></asp:LinkButton></td>
<td id="tblTransHeader1_5">
<asp:LinkButton id="lnkSortReceipt" CausesValidation="false"
OnCommand="SortData" CommandArgument="receipt" text="Deposit" Runat="server"
ForeColor="#000000"></asp:LinkButton></td>
<td id="tblTransHeader_SCROLL_BAR_HACK_COLUMN_1"> </td>
</tr>
<tr class="TableHeaders">
<td id="tblTransHeader2_0" style="BORDER-TOP: white 2px solid">All
<asp:CheckBox ID="chkAll" AutoPostBack=True
OnCheckedChanged="CheckAll" Runat="server" EnableViewState="true"/></td>
<td id="tblTransHeader2_1"> </td>
<td id="tblTransHeader2_2"> </td>
<td id="tblTransHeader2_3" style="BORDER-TOP: white 2px solid">
<asp:LinkButton id="lnkSortCat" CausesValidation="false"
OnCommand="SortData" CommandArgument="category" text="Category"
Runat="server" ForeColor="#000000"></asp:LinkButton></td>
<td id="tblTransHeader2_4" style="BORDER-TOP: white 2px solid">
<asp:LinkButton id="lnkSortSubCat" CausesValidation="false"
OnCommand="SortData" CommandArgument="subCategory" text="Sub-Category"
Runat="server" ForeColor="#000000"></asp:LinkButton></td>
<td id="tblTransHeader2_5"> </td>
<td id="tblTransHeader2_6"> </td>
<td id="tblTransHeader_SCROLL_BAR_HACK_COLUMN_2"> </td>
</tr>
</table>
</div>
<DIV id="divTransBody" style="VISIBILITY: hidden; OVERFLOW: auto;
WIDTH: 100%; HEIGHT: 180px">
<table border="0" cellspacing="0" id="tblTransBody" width="100%">
<colgroup class="ShadeColHeaderDark">
<col width="80" id="tblTransBody1" align="center">
<col width="80" id="tblTransBody2" align="center">
<col width="100" id="tblTransBody3" align="center">
<col width="155" id="tblTransBody4" align="center">
<col width="145" id="tblTransBody5" align="center">
<col width="100" id="tblTransBody6" align="center">
<col width="200" id="tblTransBody7" align="center">
</colgroup>
</HeaderTemplate>
<ItemTemplate>
<tr class="Shade_Trans_light">
<td>
<asp:CheckBox ID="chkReconciled" Checked
=<%#Container.DataItem("Reconciled")%> Runat="server" />
<asp:Label ID="lblDepositId" Runat=server Visible=false
text=<%#Container.DataItem("DepositID")%>/></td>
<asp:Label ID="lblType" Runat=server Visible=false
text=<%#Container.DataItem("Type")%>/></td>
<td><%# Format(Container.DataItem("TransDate"), "MM/dd/yyyy") %></td>
<td><%# Container.DataItem("Number")%></td>
<td colspan="2">
<asp:Label ID="lblTransDesc" text=<%#
Container.DataItem("TransDesc")%> Runat=server visible=true>
</asp:Label>
</td>
<td>
<asp:Label ID=lblPayType text=<%# Container.DataItem("PaymentType")%>
Runat=server visible=true>
</asp:Label>
</td>
<td>
<asp:Label ID=lblReceipt text=<%# Container.DataItem("Receipt") %>
runat=server>
</asp:Label></td>
</tr>
<tr class="Shade_Trans_dark">
<td colspan="3">
<asp:Label ID="lblAdjustTrans" text=<%#
Container.DataItem("AdjustTransaction")%> runat=server>
</asp:Label>
<asp:Label ID="lblBatchID" Runat=server Visible=false
text=<%#Container.DataItem("payroll_ind")%>/>
</td>
<td>
<asp:Label ID="lblCategory" text=<%# Container.DataItem("Category")%>
Runat=server visible=true>
</asp:Label></td>
<td>
<asp:Label ID=lblSubCategory text=<%#
Container.DataItem("SubCategory")%> Runat=server visible=true>
</asp:Label></td>
<td></td>
<td colspan="2">
<asp:LinkButton ForeColor ="#3333ff" CausesValidation=false
ID="lnkAdjust" CommandArgument=<%# Container.DataItem("DepositID")%>
OnCommand="lnkAdjust_Click" Runat="server">
</asp:LinkButton>
</td>
</tr>
</ItemTemplate>
<SeparatorTemplate>
<tr>
<td colspan="10" height="2" bgcolor="black" style="BORDER-RIGHT: white
1px solid; BORDER-LEFT: white 1px solid;"></td>
</tr>
</SeparatorTemplate>
<FooterTemplate>
</table> </div>
</FooterTemplate>
</asp:repeater>
<asp:button id="BtnRefresh" CausesValidation="false" Runat="server"
Text="refresh"></asp:button>
<input type="hidden" id="hdnlnkAdjust" runat="server"
NAME="hdnlnkAdjust"> <input type="hidden" id="hdnCancel" runat="server"
NAME="hdnCancel">
<asp:DataGrid id="DataGrid1" runat="server"></asp:DataGrid>
</form>
<script language="javascript" src="AlignGridHeaders.js"></script>
<script language="javascript">
<!--
Resizecolumns(tblTransHeader, tblTransBody, divTransBody, 7);
divTransHeader.style.visibility = "visible";
divTransBody.style.visibility = "visible";

//-->
</script>
<script language="javascript">
<!--
//4/11/05-Wrote this function, and added the onload & onresize events
to the <body> tag,
// to resize the transaction log based on screen resolution.
function Height()
{if ((screen.width==1024) && (screen.height==768))
return divTransBody.style.height = 402;
else if ((screen.width==800) && (screen.height==600))
return divTransBody.style.height = 192;}

// 03/06/2006-Added the SessionTimeout() function to warn a user of a
timeout.
function SessionTimeout()
{
alert("Your session will Timeout in 2 minutes!\n Any changes will be
lost if that happens.\n Click NEXT or SAVE AND FINISH LATER on the page to
save your changes.");
}
//-->
</script>
</FORM>
</BODY>
</HTML>


Expand AllCollapse All
Jun 8 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.