Solved

Finding a Panel Inside a Formview Control

Posted on 2010-08-25
10
681 Views
Last Modified: 2013-12-26
Hi,

I have a drop-down list inside a panel control which is inside a form view control. When _SelectedIndexChanged fires, I need the panel to be visible = true when the selected value of the drop-down is = to "Y" so the text box will show.

The vb in the code behind is not working and I can't figure out how to make the _SelectedIndexChanged event work.

This code worked fine until I placed it inside a form view control:

Public Sub ddlRESReturnBalancesCurrentFlg_SelectedIndexChanged(B yVal sender As Object, ByVal e As System.EventArgs) Handles ddlRESReturnBalancesCurrentFlg.SelectedIndexChanged
Dim value As Boolean
If ddlRESReturnBalancesCurrentFlg.SelectedValue = "0" Then
 value = True
Else
 value = False
End If
Me.divRESReturnCurrent2.Visible = value
End Sub

So this is what I have currently:

Markup:


 <asp:FormView ID="fvRtnMasUpdateInfo" runat="server" DataSourceID="dsRtnMasUpdateInfo"
                    AutoGenerateRows="false" DefaultMode="Edit" DataKeyNames="ExecutionStrategyID">
                    <EditItemTemplate>

                <table style="width: 625px;" cellspacing="0" cellpadding="5" border="1" style="margin: 0 auto">
                    <tr>
                        <th style="border-left: solid 1px black; border-right: solid 1px black; border-top: solid 1px black"
                            width="100%" class="H1" colspan="4">
                            <span style="float: left">
                                <asp:ImageButton CommandName="Update" ID="imgUpdate" runat="server" src="../../images/save.png" /></span>
                            <span style="float: none">Return to Master - Notify Client</span>
                        </th>
                    </tr>
                    <tr>
                        <td class="L1" align="right">
                            <asp:Label ID="lblIsLoanCurrent" runat="server" Text="Is Loan Current:" />
                        </td>
                        <td class="D1" align="left">
                            <table>
                                <tr>
                                    <td>


                                         <wc:MacroDropDownList ID="ddlRESReturnCurrentFlg" MacroFieldName="YesNo" AppendDataBoundItems="true"
                                         AddBlankValue="true"  SelectedValue='<%# Bind("RESReturnCurrentFlgX") %>'  ToolTip="RESReturnCurrentFlg" AutoPostBack="true" runat="server">
                                         </wc:MacroDropDownList>
                                       
                                       

                                    </td>
                                     <asp:Panel ID="pnlRESReturnCurrent1" runat="server" Visible="False">
                                    <div id="divRESReturnCurrent1" style="padding-left: 10px;padding-right: 10px;">
                                        <td align="right">
                                            Comment:
                                        </td>
                                        <td align="left">
                                            <asp:TextBox ID="txtRESReturnCurrentNotes" runat="server" Text='<%# Bind("RESReturnCurrentNotes") %>'></asp:TextBox>
                                        </td>
                                    </div>
                                    </asp:Panel>
                                </tr>
                            </table>
                        </td>
                    </tr>
</table>
                </table>
 <br />
                        <span class="requiredRed">* - Required Field</span>
                        <br />
                        <br />
                    </EditItemTemplate>
                    <FooterTemplate>
                        <asp:Button ID="btnUpdate" runat="server" Text="Update" CommandName="Update" CausesValidation="true"
                            ValidationGroup="EditValidation" />
                        <asp:Button ID="btnCancel" runat="server" Text="Cancel" CommandName="Cancel" CausesValidation="false" />
                    </FooterTemplate>
                </asp:FormView>







Code behind:


Private Sub fvRtnMasUpdateInfo_ItemUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.FormViewUpdateEventArgs) Handles fvRtnMasUpdateInfo.ItemUpdating

        Dim dRRESReturnCurrentFlg As DropDownList = fvRtnMasUpdateInfo.FindControl("ddlRESReturnCurrentFlg")
        Dim dRRESReturnBalancesCurrentFlg As DropDownList = fvRtnMasUpdateInfo.FindControl("ddlRESReturnBalancesCurrentFlg")
        Dim dRRESReturnExpensesPaidFlg As DropDownList = fvRtnMasUpdateInfo.FindControl("ddlRESReturnExpensesPaidFlg")


 If dRRESReturnCurrentFlg.SelectedValue = "Y" Then
            e.NewValues("RESReturnCurrentFlgX") = "Y"
            fvRtnMasUpdateInfo.FindControl("pnlRESReturnCurrent1").Visible = True
        ElseIf dRRESReturnCurrentFlg.SelectedValue = "N" Then
            e.NewValues("RESReturnCurrentFlgX") = "N"
            fvRtnMasUpdateInfo.FindControl("pnlRESReturnCurrent1").Visible = False
        End If

       
End Sub

But nothing happens except the autopostback for the drop-down list fires. The vb above is not being run at all. What am I missing here?

The object is to reveal the text box if the drop-down selection is "Y" either by selecting "Yes" in the drop-down control of on page load if that field contains data that = "Y"

Any help would be appreciated!






0
Comment
Question by:jaysch
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
10 Comments
 
LVL 6

Expert Comment

by:Rhino1272
ID: 33521239
Is the _SelectedIndexChanged event firing at all?
0
 

Author Comment

by:jaysch
ID: 33521846
The following code:

Public Sub ddlRESReturnBalancesCurrentFlg_SelectedIndexChanged(B yVal sender As Object, ByVal e As System.EventArgs) Handles ddlRESReturnBalancesCurrentFlg.SelectedIndexChanged
Dim value As Boolean
If ddlRESReturnBalancesCurrentFlg.SelectedValue = "0" Then
 value = True
Else
 value = False
End If
Me.divRESReturnCurrent2.Visible = value
End Sub


Fires OK when not inside a Formview. But I can't figure out how to make it run witha formview.

0
 
LVL 6

Expert Comment

by:Rhino1272
ID: 33522047
Is all of this inside an UpdatePanel by any chance?   If so, you might need to add a PostBackTrigger.

       <asp:UpdatePanel id="UpdatePanel1" runat="server" >
        <Triggers>
            <asp:PostBackTrigger ControlID="ddlRESReturnCurrentFlg"/>
        </Triggers>
0
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 

Author Comment

by:jaysch
ID: 33522074
Interesting. Yes, it's all inside an update panel
0
 
LVL 6

Expert Comment

by:Rhino1272
ID: 33522194
So did adding the Trigger work?
0
 

Author Comment

by:jaysch
ID: 33523072
No, unfortunately not. Placed the code in the markup directly under the Update panel tag Error said that the ddl control couldn't be found.
0
 
LVL 6

Expert Comment

by:Rhino1272
ID: 33523372
I am trying to recreate your issue.  I will get back with you shortly.
0
 

Author Comment

by:jaysch
ID: 33523676
Tnx!
0
 
LVL 6

Accepted Solution

by:
Rhino1272 earned 500 total points
ID: 33523715
OK try this:

1) Change your code behind signature from:

Public Sub ddlRESReturnBalancesCurrentFlg_SelectedIndexChanged(B yVal sender As Object, ByVal e As System.EventArgs) Handles ddlRESReturnBalancesCurrentFlg.SelectedIndexChanged

TO

Public Sub ddlRESReturnBalancesCurrentFlg_SelectedIndexChanged(B yVal sender As Object, ByVal e As System.EventArgs)

2) Add this to your dropdownlist declaration:

onselectedindexchanged="ddlRESReturnBalancesCurrentFlg_SelectedIndexChanged"
0
 

Author Closing Comment

by:jaysch
ID: 33538378
Rhino172 - That did the trick. Thanks for your help!
0

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses
Course of the Month7 days, 3 hours left to enroll

622 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question