That doesn't work in a method like ShowHidePanel because e is of type System.EventArgs instead of DatalistCommandEventArgs. 'Item' is not a member of System.EventArgs
Main Topics
Browse All TopicsI'm not able to find controls in an EditItemTemplate. I have a datalist which is bound on Not IsPostBack, and it has an item template simply displaying a list of vendors. When i click on the Edit LinkButton, my EditItemTemplate is loaded with a form to change info about that vendor. I load the form fine and can populate the fields how i want to. however i also want to have checkboxes (only one here for simplicity) which show hidden parts of the form that update more advanced portions.
Here is my Datalist definition:
<asp:DataList id="dtlLinks" runat="server" OnEditCommand="dtlLinks_Ed
<ItemTemplate>
<asp:LinkButton Text="Edit" CommandName="edit" runat="server" ID="lnkEdit" NAME="lnkEdit" /> -
<%# Container.DataItem("Vendor
</ItemTemplate>
<EditItemTemplate>
<asp:CheckBox id="chkChangeLinkImage" runat="server" Text="Change?" AutoPostBack="True"
OnCheckedChanged="ShowHide
<asp:Panel id="pnlNewLinkImage" runat="server" Visible="False">
<asp:TextBox id="txtInPanel" runat="server" Text="You Made It!" />
</asp:Panel>
<asp:LinkButton id="lnkUpdate" Text="Update" CommandName="update" runat="server" />
<asp:LinkButton id="lnkCancel" Text="Cancel" CommandName="cancel" runat="server" />
<asp:LinkButton id="lnkDelete" Text="Delete" CommandName="delete" runat="server" />
</EditItemTemplate>
</asp:DataList>
Now what i want to happen is when chkChangeLinkImage is checked, i want to show the hidden panel. My Code behind (selections) looks like:
===
Page_Load
===
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.PageTitle = "SamplePage.aspx"
If Not IsPostBack Then
BindList()
End If
End Sub
===
===
Sub dtLinks_EditCommand
===
Sub dtlLinks_EditCommand(ByVal
dtlLinks.EditItemIndex = e.Item.ItemIndex
BindList()
End Sub
===
===
Sub ShowHidePanel - Called when checkbox is checked
===
Sub showHidePanel(ByVal s As Object, ByVal e As System.EventArgs) Handles chkChageLinkImage.CheckedC
Dim pnl As Panel
Dim chk As CheckBox
Try
chk = CType(FindControl("chkChan
pnl = CType(FindControl("pnlNewL
Response.Write("ctype ID = " & CType(FindControl("pnlNewL
Catch exp As NullReferenceException
Response.Write("it messed up: e = " & exp.Message)
End Try
End Sub
===
I can't find controls. I always get thrown into the NullReferenceException. How/Where Do i find these controls so i can make this work?? Leave any questions that you may need about my code or just ask for other parts as i will be checking this very frequently
Thank you
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
I am sorry, u are right..
in this case:
s in "Sub showHidePanel(ByVal s As Object, ByVal e As System.EventArgs)"
will be chkChangeLinkImage checkbox
that means instead of
chk = CType(FindControl("chkChan
write
chk = CType(s, CheckBox)
and to get pnlNewLinkImage panel
get the parent of s as follow:
Dim objControl as Control = s.Parent
then get pnlNewLinkImage as follow
pnl = CType(objControl.FindContr
Business Accounts
Answer for Membership
by: Hassan_GhanemPosted on 2005-07-27 at 13:26:45ID: 14540762
first of all hanged
geLinkImag e"), CheckBox) chkChangeL inkImage") , CheckBox)
inkImage") , Panel) pnlNewLink Image"), Panel)
no need for the following statment u should remove it
Handles chkChageLinkImage.CheckedC
and instead of
chk = CType(FindControl("chkChan
try
chk = CType(e.Item.FindControl("
and instead of
pnl = CType(FindControl("pnlNewL
try
pnl = CType(e.Item.FindControl("