Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Finding a Panel Inside a Formview Control

Posted on 2010-08-25
10
Medium Priority
?
685 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 2000 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

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

971 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