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.Ite ms(I).FindContr ol("chkReconcil ed")
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.Fin dControl("chkAl l")
CheckAll.Checke d = 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="No ne" %>
<%@ Page Language="vb" AutoEventWireup ="false"
Codebehind="Ban k_recon_deposit .aspx.vb"
Inherits="IAMVF O_DEV.Bank_reco n_deposit"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>Bank_rec on_deposit</title>
<META http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta content="Micros oft Visual Studio.NET 7.0" name="GENERATOR ">
<meta content="Visual Basic 7.0" name="CODE_LANG UAGE">
<meta content="JavaSc ript" name="vs_defaul tClientScript">
<meta content="http://schemas.microso ft.com/intellisense/ie5"
name="vs_target Schema">
<LINK href="Styles.cs s" type="text/css" rel="stylesheet ">
</HEAD>
<BODY onresize="retur n Height();"
onload="setTime out('SessionTim eout()',1080000 ); return Height();"
class="backgrou nd">
<!--<p class="sectionH eader">Bank Reconciliation</p>-->
<form id="frmBankReco nDep" method="post" runat="server">
<TABLE id="Table1" cellSpacing="0" cellPadding="0" width="100%" border="0">
<TR>
<TD class="Report_H eaderColor" 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 >"
DESIGNTIMEDRAGD ROP="65"></asp:button></TD>
</TR>
</TABLE>
<table cellSpacing="1" cellPadding="3" style="FONT-SIZE: 11pt; WIDTH:
100%">
<tr>
<TD class="Report_H eaderColor" align="middle">
<asp:Button id="btnCleared " runat="server" Text="Total Cleared
Deposits" Width="141px"></asp:Button></TD>
<td class="Report_H eaderColor" style="WIDTH: 175px">
<asp:Label id="lblAmount" runat="server"
Font-Size="11pt"></asp:Label></td>
<td rowSpan="2" class="Report_H eaderColor" 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="divTransHea der" style="VISIBILI TY: hidden">
<table id="tblTransHea der" border="0" cellspacing="0"
class="HeaderTa ble">
<colgroup class="ShadeCol HeaderDark">
<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="TableHea ders">
<td id="tblTransHea der1_0">
<asp:label text="R/C" id="lblReconcil ed"
Runat="server"> </asp:label></td>
<td id="tblTransHea der1_1">
<asp:LinkButt on id="lnkSortDate " CausesValidatio n="false"
OnCommand="Sort Data" CommandArgument ="transdate" text="Date" Runat="server"
ForeColor="#000 000"></asp:LinkButton> </td>
<td id="tblTransHea der1_2">
<asp:LinkButt on id="lnkSortNumb er" CausesValidatio n="false"
OnCommand="Sort Data" CommandArgument ="depositID" text="Number" Runat="server"
ForeColor="#000 000"></asp:LinkButton> </td>
<td id="tblTransHea der1_3" colspan="2">
<asp:LinkButt on id="lnkSortDesc " CausesValidatio n="false"
OnCommand="Sort Data" CommandArgument ="TransDesc" text="Descripti on"
Runat="server" ForeColor="#000 000"></asp:LinkButton> </td>
<td id="tblTransHea der1_4">
<asp:LinkButt on id="lnkSortPayT ype" CausesValidatio n="false"
OnCommand="Sort Data" CommandArgument ="paymenttyp e" text="Payment Type"
Runat="server" ForeColor="#000 000"></asp:LinkButton> </td>
<td id="tblTransHea der1_5">
<asp:LinkButt on id="lnkSortRece ipt" CausesValidatio n="false"
OnCommand="Sort Data" CommandArgument ="receipt" text="Deposit" Runat="server"
ForeColor="#000 000"></asp:LinkButton> </td>
<td id="tblTransHea der_SCROLL_BAR_ HACK_COLUMN_1"> </td>
</tr>
<tr class="TableHea ders">
<td id="tblTransHea der2_0" style="BORDER-TOP: white 2px solid">All
<asp:CheckBox ID="chkAll" AutoPostBack=Tr ue
OnCheckedChange d="CheckAll" Runat="server" EnableViewState ="true"/></td>
<td id="tblTransHea der2_1"> </td>
<td id="tblTransHea der2_2"> </td>
<td id="tblTransHea der2_3" style="BORDER-TOP: white 2px solid">
<asp:LinkButt on id="lnkSortCat " CausesValidatio n="false"
OnCommand="Sort Data" CommandArgument ="category" text="Category"
Runat="server" ForeColor="#000 000"></asp:LinkButton> </td>
<td id="tblTransHea der2_4" style="BORDER-TOP: white 2px solid">
<asp:LinkButt on id="lnkSortSubC at" CausesValidatio n="false"
OnCommand="Sort Data" CommandArgument ="subCategor y" text="Sub-Category"
Runat="server" ForeColor="#000 000"></asp:LinkButton> </td>
<td id="tblTransHea der2_5"> </td>
<td id="tblTransHea der2_6"> </td>
<td id="tblTransHea der_SCROLL_BAR_ HACK_COLUMN_2"> </td>
</tr>
</table>
</div>
<DIV id="divTransBod y" style="VISIBILI TY: hidden; OVERFLOW: auto;
WIDTH: 100%; HEIGHT: 180px">
<table border="0" cellspacing="0" id="tblTransBod y" width="100%">
<colgroup class="ShadeCol HeaderDark">
<col width="80" id="tblTransBod y1" align="center">
<col width="80" id="tblTransBod y2" align="center">
<col width="100" id="tblTransBod y3" align="center">
<col width="155" id="tblTransBod y4" align="center">
<col width="145" id="tblTransBod y5" align="center">
<col width="100" id="tblTransBod y6" align="center">
<col width="200" id="tblTransBod y7" align="center">
</colgroup>
</HeaderTemplate>
<ItemTemplate >
<tr class="Shade_Tr ans_light">
<td>
<asp:CheckBox ID="chkReconcil ed" Checked
=<%#Container.D ataItem("Reconc iled")%> Runat="server" />
<asp:Label ID="lblDepositI d" Runat=server Visible=false
text=<%#Contain er.DataItem("De positID")%>/></td>
<asp:Label ID="lblType" Runat=server Visible=false
text=<%#Contain er.DataItem("Ty pe")%>/></td>
<td><%# Format(Containe r.DataItem("Tra nsDate"), "MM/dd/yyyy") %></td>
<td><%# Container.DataI tem("Number")%> </td>
<td colspan="2">
<asp:Label ID="lblTransDes c" text=<%#
Container.DataI tem("TransDesc" )%> Runat=server visible=true>
</asp:Label>
</td>
<td>
<asp:Label ID=lblPayType text=<%# Container.DataI tem("PaymentTyp e")%>
Runat=server visible=true>
</asp:Label>
</td>
<td>
<asp:Label ID=lblReceipt text=<%# Container.DataI tem("Receipt") %>
runat=server>
</asp:Label></td>
</tr>
<tr class="Shade_Tr ans_dark">
<td colspan="3">
<asp:Label ID="lblAdjustTr ans" text=<%#
Container.DataI tem("AdjustTran saction")%> runat=server>
</asp:Label>
<asp:Label ID="lblBatchID " Runat=server Visible=false
text=<%#Contain er.DataItem("pa yroll_ind")%>/>
</td>
<td>
<asp:Label ID="lblCategory " text=<%# Container.DataI tem("Category") %>
Runat=server visible=true>
</asp:Label></td>
<td>
<asp:Label ID=lblSubCatego ry text=<%#
Container.DataI tem("SubCategor y")%> Runat=server visible=true>
</asp:Label></td>
<td></td>
<td colspan="2">
<asp:LinkButt on ForeColor ="#3333ff" CausesValidatio n=false
ID="lnkAdjust" CommandArgument =<%# Container.DataI tem("DepositID" )%>
OnCommand="lnkA djust_Click" Runat="server">
</asp:LinkButton>
</td>
</tr>
</ItemTemplate>
<SeparatorTempl ate>
<tr>
<td colspan="10" height="2" bgcolor="black" style="BORDER-RIGHT: white
1px solid; BORDER-LEFT: white 1px solid;"></td>
</tr>
</SeparatorTempla te>
<FooterTemplate >
</table> </div>
</FooterTemplate>
</asp:repeater>
<asp:button id="BtnRefresh " CausesValidatio n="false" Runat="server"
Text="refresh"> </asp:button>
<input type="hidden" id="hdnlnkAdjus t" runat="server"
NAME="hdnlnkAdj ust"> <input type="hidden" id="hdnCancel" runat="server"
NAME="hdnCancel ">
<asp:DataGrid id="DataGrid1" runat="server"> </asp:DataGrid>
</form>
<script language="javas cript" src="AlignGridH eaders.js"></script>
<script language="javas cript">
<!--
Resizecolumns(t blTransHeader, tblTransBody, divTransBody, 7);
divTransHeader. style.visibilit y = "visible";
divTransBody.st yle.visibility = "visible";
//-->
</script>
<script language="javas cript">
<!--
//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.st yle.height = 402;
else if ((screen.width= =800) && (screen.height= =600))
return divTransBody.st yle.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>