User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 373,096 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,946 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 471 | Replies: 3
Reply
Join Date: Mar 2008
Posts: 7
Reputation: s627y is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
s627y s627y is offline Offline
Newbie Poster

Where to insert this code?

  #1  
Mar 19th, 2008
I have a multiview inside a form view. The multiview active index is based on a dropdownlist selection, I found out that I need to put this line somewhere:
  1. <script runat="server">
  2. Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)
  3. MultiView2.ActiveViewIndex = DropDownList1.SelectedValue
  4. End Sub
  5. </script>

My page has a masterpage, so the main page looks like this:

  1. <%@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="test.aspx.vb" Inherits="test" title="test" %>
  2.  
  3. <asp:Content ID="Content1" ContentPlaceHolderID="mainContent" Runat="Server">
  4.  
  5. <asp:FormView ID="FormView1" runat="server" DataSourceID="sdsDetail" DefaultMode="Edit">
  6.  
  7. <EditItemTemplate>
  8.  
  9. <asp:DropDownList ID="DropDownList1" runat="server" SelectedValue='<%# Bind("Active") %>' AutoPostBack="True" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
  10.  
  11. <asp:ListItem Value=""></asp:ListItem>
  12.  
  13. <asp:ListItem Value="A">Active Employee </asp:ListItem>
  14.  
  15. <asp:ListItem Value="R">Retired</asp:ListItem>
  16.  
  17. </asp:DropDownList>
  18.  
  19. <asp:MultiView ID="MultiView2" runat="server">
  20. <asp:View ID="View1" runat="server">
  21. <asp:ListBox ID="ListBox1" runat="server" DataSourceID="odsDept" DataTextField="Dept_name"
  22. DataValueField="Dept_name" SelectedValue='<%# bind("Dept") %>' Width="232px">
  23. </asp:ListBox><asp:ObjectDataSource ID="odsDept" runat="server" OldValuesParameterFormatString="original_{0}"
  24. SelectMethod="GetDept" TypeName="TableAdapters.A_TableAdapter"></asp:ObjectDataSource>
  25. </asp:View>
  26. <asp:View ID="View2" runat="server">
  27. <asp:ListBox ID="ListBox2" runat="server" DataSourceID="odsB" DataTextField="Group_Name"
  28. DataValueField="Group_Name" SelectedValue='<%# bind("Dept") %>' Width="232px">
  29. </asp:ListBox><asp:ObjectDataSource ID="odsB" runat="server" OldValuesParameterFormatString="original_{0}"
  30. SelectMethod="GetGroup" TypeName="TableAdapters.B_TableAdapter"></asp:ObjectDataSource>
  31. </asp:View>
  32. </asp:MultiView>
  33. </EditItemTemplate>
  34. </asp:FormView>
  35. </asp:Content>

I have had people suggesting me to put it in the vb file like this:
Partial Class list_pages_Details
    Inherits System.Web.UI.Page

    'Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)
    '    dim MultiView mv
    '    dim DropDownList ddl

    '    mv = (MultiView)FormView1.FindControl("MultiView2")
    '    ddl = (DropDownList)FormView1.FindControl("DropDownList1")

    '    mv.ActiveViewIndex = ddl.SelectedValue
    'End Sub

    Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)

    End Sub
End Class

I tried putting the sub inside FormView, inside Edit Template, inside master file....
Anywhere I put it, same error:
name mv not declared....

Please help me, where can I put it, or how can I achieve what I need to do?

Thank you for your time!!!
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Aug 2005
Location: Ohio
Posts: 204
Reputation: plazmo is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 16
plazmo's Avatar
plazmo plazmo is offline Offline
Posting Whiz in Training

Re: Where to insert this code?

  #2  
Mar 19th, 2008
you need to put that code in your test.aspx.vb file.
Reply With Quote  
Join Date: Mar 2008
Posts: 7
Reputation: s627y is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
s627y s627y is offline Offline
Newbie Poster

Re: Where to insert this code?

  #3  
Mar 19th, 2008
Originally Posted by plazmo View Post
you need to put that code in your test.aspx.vb file.


I did, and it complaints
1. end of statement expected.
2. mv, ddl is not declared...

any suggestions? thank you.

my VB file looks like:
  1. Partial Class test
  2. Inherits System.Web.UI.Page
  3. Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)
  4. dim mv as MultiView = (MultiView)FormView1.FindControl("MultiView2")
  5. dim ddl as DropDownList = (DropDownList)FormView1.FindControl("DropDownList1")
  6. mv.ActiveViewIndex = ddl.SelectedValue
  7. End Sub
  8. End Class
Last edited by s627y : Mar 19th, 2008 at 2:08 pm.
Reply With Quote  
Join Date: Mar 2008
Posts: 7
Reputation: s627y is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
s627y s627y is offline Offline
Newbie Poster

Re: Where to insert this code?

  #4  
Mar 19th, 2008
I got it fixed, thank you!

looks like:
  1. Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)
  2. Dim mv As MultiView = FormView1.FindControl("MultiView2")
  3. Dim ddl As DropDownList = FormView1.FindControl("DropDownList1")
  4. mv.ActiveViewIndex = ddl.SelectedValue
  5. End Sub
  6.  
  7.  
  8.  
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb ASP.NET Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the ASP.NET Forum

All times are GMT -4. The time now is 4:52 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC