Where to insert this code?

Please support our ASP.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Mar 2008
Posts: 7
Reputation: s627y is an unknown quantity at this point 
Solved Threads: 0
s627y s627y is offline Offline
Newbie Poster

Where to insert this code?

 
0
  #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:
  1. Partial Class list_pages_Details
  2. Inherits System.Web.UI.Page
  3.  
  4. 'Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)
  5. ' dim MultiView mv
  6. ' dim DropDownList ddl
  7.  
  8. ' mv = (MultiView)FormView1.FindControl("MultiView2")
  9. ' ddl = (DropDownList)FormView1.FindControl("DropDownList1")
  10.  
  11. ' mv.ActiveViewIndex = ddl.SelectedValue
  12. 'End Sub
  13.  
  14. Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)
  15.  
  16. End Sub
  17. End Class
  18.  

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!!!
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 206
Reputation: plazmo is an unknown quantity at this point 
Solved Threads: 16
plazmo's Avatar
plazmo plazmo is offline Offline
Posting Whiz in Training

Re: Where to insert this code?

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

Re: Where to insert this code?

 
0
  #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 3:08 pm.
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 7
Reputation: s627y is an unknown quantity at this point 
Solved Threads: 0
s627y s627y is offline Offline
Newbie Poster

Re: Where to insert this code?

 
0
  #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
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC