473,320 Members | 1,884 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Events not firing within formview

Events not firing within FormView:

I have a set of tabs (menu items) and a multiview nested within a formview. I want to be able to change view dependent on which menu item (tab) has been selected. Outside of formview I could go :

multiview1.activeViewIndex = 1 (for a menu item click event)

I would have expected to have been able to write the following for a menu item click event within a formview, but no events fire.

formview1.findcontrol("multiview1").activeviewinde x = 1

Can anybody help please. I am new to asp .net so I would appreciate it being kept as simple as possible. Thanks in advance. Code:

Expand|Select|Wrap|Line Numbers
  1. <%@ Page Trace="true" %> <%@ Import Namespace="System.Data" %> <%@ Import Namespace="System.Data.SqlClient" %> <%@ Import Namespace="System.Web.UI.WebControls" %> <%@ Register assembly="AjaxControlToolkit" 
  2.  
  3. namespace="AjaxControlToolkit" tagprefix="asp" %> <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” 
  4.  
  5. “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”> <Script Runat="Server">
  6.  
  7. Sub Page_Load
  8.  
  9. If not ispostback then
  10.  
  11. Dim IDtransfer as string
  12. Dim RetPersSQL as string
  13. Dim idInt as integer
  14. Dim MenuTwo as control
  15. Dim MenuOne as control
  16.  
  17.  
  18. idtransfer = Convert.ToString(Request.QueryString("Id"))
  19. lbltransfer.text = idtransfer
  20. idInt = convert.toint32(idtransfer)
  21.  
  22.  
  23. Dim parameter1 As New System.Web.UI.WebControls.Parameter("Id", Data.DbType.Int32)
  24. parameter1.DefaultValue = idInt
  25. SQLReturnPerson.SelectParameters.Add(parameter1)
  26.  
  27.  
  28. menutwo = findcontrol("frmClientData").FindControl("menu2")
  29. Menutwo.visible="false"
  30.  
  31. MenuOne = findcontrol("frmClientData").FindControl("menu1") 
  32. MenuOne.visible="true"
  33.  
  34. End if
  35.  
  36. End Sub
  37.  
  38. Public Sub Menu1_MenuItemClick(ByVal sender As Object, ByVal e As MenuEventArgs)
  39. Dim ActiveTab as integer 
  40. Activetab = Int32.Parse(e.Item.Value)
  41. Dim MV1 as multiview
  42. MV1 = findcontrol("frmClientData").FindControl("multiview1")
  43. MV1.ActiveViewIndex = Activetab
  44. End sub
  45.  
  46. Public Sub Menu2_MenuItemClick(ByVal sender As Object, ByVal e As MenuEventArgs)
  47. Dim ActiveTab as integer 
  48. Activetab = Int32.Parse(e.Item.Value)
  49. Dim MV1 as multiview
  50. MV1 = findcontrol("frmClientData").FindControl("multiview1")
  51. MV1.ActiveViewIndex = Activetab
  52. End sub
  53.  
  54. </Script> <html> <head runat="Server"><title>Person Details</title> <style type="text/css">
  55. html     {
  56.     background-color:silver;
  57.     }
  58. .tabs
  59.     {
  60.     position:relative; top:1px; left:1px;
  61.     }
  62. .tab     {
  63.     border:solid 1px black; background-color:red; padding:2px     
  64.  
  65.     10px;
  66.     }
  67. .selectedTab
  68.     {
  69.     background-color:white; border-bottom:solid 1px white;
  70.     }
  71. </style> </head> <body> <form runat="Server"> <asp:SqlDataSource ID="SQLReturnPerson" runat="server" 
  72.         ConnectionString="<%$ ConnectionStrings:ViewPointConnectionString %>" 
  73.         SelectCommand="SELECT * FROM [Person] WHERE [Id]=@Id"> </asp:SqlDataSource> <br> <asp:FormView
  74. id="frmClientData"
  75. DataSourceID="SQLReturnPerson"
  76. DataKeyNames="Id"
  77. AllowPaging="false"
  78. runat="Server" > <ItemTemplate> <h1><%# Eval(“Id") %></h1><br> <%# Eval(“Client_forename") %> <%# Eval(“initials") %> <br> <br> <br> <div> <asp:Menu id="Menu1" Orientation="Horizontal" CssClass="tabs" 
  79.  
  80. Runat="server"> <staticmenuitemstyle backcolor="LightBlue"
  81.           forecolor="Black"
  82.           borderstyle="Solid"
  83.           borderwidth="1"
  84.           bordercolor="Black"
  85.          itemspacing="10"
  86.     horizontalpadding="40" /> <StaticSelectedStyle backcolor="White" borderstyle="Solid"
  87.           bordercolor="Black"
  88.           borderwidth="1" /> <Items> <asp:MenuItem Text="Tab 1" Value="0" Selected="true" /> <asp:MenuItem Text="Tab 2" Value="1" /> <asp:MenuItem Text="Tab 3" Value="2" /> </Items> </asp:Menu> <asp:Menu id="Menu2" Orientation="Horizontal" CssClass="tabs" 
  89.  
  90. Runat="server"> <staticmenuitemstyle backcolor="LightBlue"
  91.           forecolor="Black"
  92.           borderstyle="Solid"
  93.           borderwidth="5"
  94.           bordercolor="Black"
  95.          itemspacing="10"
  96.     horizontalpadding="40" /> <StaticSelectedStyle backcolor="White" borderstyle="Solid"
  97.           bordercolor="Black"
  98.           borderwidth="1" /> <Items> <asp:MenuItem Text="Tab 4" Value="0" Selected="true" /> <asp:MenuItem Text="Tab 5" Value="1" /> <asp:MenuItem Text="Tab 6" Value="2" /> </Items> </asp:Menu> </div> <div class="tabContents"> <asp:MultiView id="MultiView1"  ActiveViewIndex="0" Runat="server"> <asp:View ID="View1" runat="server"> <br>This is the first view 1  
  99. <br> <br> <h1><%# Eval(“Id") %></h1><br> <%# Eval(“Client_forename") %> <%# Eval(“initials") %> </asp:View> <asp:View ID="View2" runat="server"> <br>This is the second view 2
  100. <br> <h1><%# Eval(“Id") %></h1><br> <%# Eval(“Client_forename") %> <%# Eval(“initials") %> </asp:View> <asp:View ID="View3" runat="server"> <br>This is the third view 3 
  101.  
  102. </asp:View> </asp:MultiView> </div> <br> </ItemTemplate> </asp:FormView> <div> <asp:Label
  103.   ID="lbltransfer"
  104.   ForeColor="Red"
  105.   Font-Bold="True"
  106.   Runat="Server" /> </div> </form> </body> </html>
Feb 4 '14 #1
0 1138

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Kory Pukash | last post by:
I have an asp.net(2003) form that uses web server controls event architecture. The form has edit, cancel, save, delete buttons on it. When the delete button is clicked the following events fire. ...
0
by: Daves | last post by:
<form ID="Form1" runat="server"> <asp:FormView ID="FormView1" Runat="server"> <ItemTemplate> <asp:Button ID="Button1" runat="server" Text="Breyta" CommandName="Edit"/> ... This is what won't...
1
by: jlw | last post by:
Hello all, I have a strange one here. in VS.NET VB web application, I can create a webform, place server controls on it, run it, and server controls fire all the right events in the postback...
1
by: geneb | last post by:
I've got a number of tabs with text boxes on them. When you hit the last textbox on a tab, it checks to see if the next tab is a valid destination, then goes to it if so. Unfortunately, when...
3
by: gellis99 | last post by:
I've searched several discussions on this topic and haven't been able to resolve my issue. I have a function I call within the page_load event of a page. This function makes a call to the...
0
by: TJHerman | last post by:
I have a dropdown list in a Formview that includes a number of fields in the SQLDatasource. I want to be able to get the value of one of the fields in the Datasource that is not the...
3
by: Leo Smith | last post by:
I have a problem with some code that fires an onclick event for an image. What I did was create a group of images to work like a button. The mouseover, mousedown, and mouseout events swap images to...
0
by: Chris | last post by:
I have a formview nested within a formview. It child formview will be the same in both the Insert and Update template in the parent formview. How do place the formview in the templates without...
5
by: =?Utf-8?B?VmFubmk=?= | last post by:
Hi, I have a component where I need to have thread-safe access to a list. Operations on the list are done in critical sections (lock (lockObject) { ... } ) in the usual way, to make sure that no...
0
by: JCH1 | last post by:
I have a table within a formview and have been editing the edititemtemplate. I have been changing some of my text fields to dropdownlists. The dropdown lists are linked to sqldatasources. When I...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.