Solved

Finding a Panel Inside a Formview Control

Posted on 2010-08-25
10
679 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
  • 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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Iteration Help (Asp.net VB) 5 25
Problem to line 23 55
Phone Does Not Abide By CSS Breakpoint For Navigation Controls 6 22
Set WorkSheet  not Working 9 44
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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 utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

820 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