Hello guys,
thanks for the help in advance
My problem is that whatever input or selection control i have in the detailsview (specifically in the edititemtemplate) the control's ID id never declared in the script. What could be the reason for this?
I was thinking that probably a function is to be returned to the script (thats just my guess anyway).
My code is below, the purpose is to have a dropdownlist that populates another DDL
Thanks for the help in advance
Peace
Cool Nuh Man
thanks for the help in advance
My problem is that whatever input or selection control i have in the detailsview (specifically in the edititemtemplate) the control's ID id never declared in the script. What could be the reason for this?
I was thinking that probably a function is to be returned to the script (thats just my guess anyway).
My code is below, the purpose is to have a dropdownlist that populates another DDL
Code:
<script runat="server">
Sub Generate(ByVal a As Object, ByVal y As EventArgs)
Dim ddl As DropDownList
Dim ddl2 As DropDownList
Dim lbl As Label
If ddl.SelectedValue = 1 Then
lbl.Text = "value 1 selected"
ddl2.Items.Clear()
ddl2.Items.Add(New ListItem("CABS", "1"))
ddl2.Items.Add(New ListItem("MIS", "2"))
ElseIf ddl.SelectedValue = 2 Then
lbl.Text = "value 2 selected"
ddl2.Items.Clear()
ddl2.Items.Add(New ListItem("BBA", "1"))
ddl2.Items.Add(New ListItem("ADB", "2"))
End If
End Sub
</script>
<html>
<head runat="server">
<title>Nested Dropdownlist</title>
</head>
<body>
<form id="form1" runat="server">
<asp:AccessDataSource ID="ADS" runat="server" DataFile="registry.mdb"
SelectCommand="SELECT * FROM CSDept ">
</asp:AccessDataSource>
<asp:Detailsview runat="server" id="DV" DataSourceID="ADS"
allowpaging=true AutoGenerateRows=false AutoGenerateEditButton=true >
<fields>
<asp:BoundField
headertext="ID No."
datafield="id" />
<asp:boundfield
headertext="First Name"
datafield="fname"/>
<asp:boundfield
headertext="Last Name"
datafield="lname"/>
<asp:templatefield HeaderText="Programme">
<editItemTemplate>
<asp:DropDownList ID="DDL" runat="server" AutoPostBack=true OnTextChanged="generate">
<asp:ListItem Value=1>Computer</asp:ListItem>
<asp:ListItem Value=2>Business</asp:ListItem>
</asp:DropDownList>
<asp:dropdownlist runat="server" ID="ddl2" Width="100"></asp:dropdownlist>
</editItemTemplate>
</asp:templatefield>
</fields>
</asp:detailsview>
</form>
</body>
</html>
Peace
Cool Nuh Man