A GridView Object if populating a DetailsView Object and I have a dropdownlist within the DetailsView which, when the user selects a value in the GridView results in a singular value in the dropdownlist in the DetailsView.
The user need to be able to repopulate the dropdownlist with the remaining data values when needed. How can I capture the <clicking> of the dropdownlist in order for meto re-populate the dropdownlist with the corresponding values.
I have:
<asp:UpdatePanel ID="upLD2" runat ="server" >
Along with:
Public Sub LocationDescription2_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles LocationDescription2.SelectedIndexChanged
Dim LocationDescription2 As DropDownList = CType(dvContact.FindControl("LD2"), DropDownList)
Protected Sub LocationDescription2_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles LocationDescription2.SelectedIndexChanged
Dim ddl As DropDownList = DirectCast(sender, DropDownList)
Label1.Text = "You have selected:" & ddl.SelectedItem.Text
End Sub
I need to capture the click event of the dropdownlist as initially there will only be on record and selecting that one record will not change the index value. So, how can I capture the forced click event of the dropdownlist using <"LocationDescription2.Attributes.Add("onclick",
"function")>?
How would this function be written? When the user selects the initial singular record I will need to repopulate the same dropdownlist object with records.
Ayomide
Member
52 Points
223 Posts
How to force an OnClick Event in a DropDownList Control
Mar 19, 2009 05:27 PM|LINK
The situation:
A GridView Object if populating a DetailsView Object and I have a dropdownlist within the DetailsView which, when the user selects a value in the GridView results in a singular value in the dropdownlist in the DetailsView.
The user need to be able to repopulate the dropdownlist with the remaining data values when needed. How can I capture the <clicking> of the dropdownlist in order for meto re-populate the dropdownlist with the corresponding values.
I have:
<asp:UpdatePanel ID="upLD2" runat ="server" >
<ContentTemplate >
<asp:DropDownList ID="LD2" runat="server" AutoPostBack="True"
DataSourceID="odsLByD"
OnSelectedIndexChanged="LD2_SelectedIndexChanged"
DataTextField="LD" DataValueField="LCode">
</asp:DropDownList>
<asp:ObjectDataSource ID="odsLByDi" runat="server"
OldValuesParameterFormatString="original_{0}"
SelectMethod="GetLByEmpID"
TypeName="LBLL">
<SelectParameters>
<asp:ControlParameter ControlID="grdEmp" Name="EmpD" PropertyName="SelectedValue"
Type="String" />
</SelectParameters>
</asp:ObjectDataSource>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID ="LD2" EventName ="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
</EditItemTemplate>
Along with:
Public Sub LocationDescription2_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles LocationDescription2.SelectedIndexChanged
Dim LocationDescription2 As DropDownList = CType(dvContact.FindControl("LD2"), DropDownList)
lblupdatePanel.Text = "You selected <b>" + sender.Text + "</b>."
End Sub*
*Which by the way does not return a value.
mcsekar
Member
56 Points
13 Posts
Re: How to force an OnClick Event in a DropDownList Control
Mar 19, 2009 08:13 PM|LINK
dropdownlist.attributes.add("onclick","function")
Ayomide
Member
52 Points
223 Posts
Re: How to force an OnClick Event in a DropDownList Control
Mar 20, 2009 01:32 PM|LINK
How would I use the Attributes.Add("... ?
Ayomide
vinz
All-Star
128424 Points
18131 Posts
MVP
Re: How to force an OnClick Event in a DropDownList Control
Mar 20, 2009 02:00 PM|LINK
Try
Protected Sub LocationDescription2_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles LocationDescription2.SelectedIndexChanged Dim ddl As DropDownList = DirectCast(sender, DropDownList) Label1.Text = "You have selected:" & ddl.SelectedItem.Text End SubMessageBox Controls for WebForms | Blog | Twitter | Linkedin
Ayomide
Member
52 Points
223 Posts
Re: How to force an OnClick Event in a DropDownList Control
Mar 20, 2009 03:24 PM|LINK
HI Vinz,
I need to capture the click event of the dropdownlist as initially there will only be on record and selecting that one record will not change the index value. So, how can I capture the forced click event of the dropdownlist using <"LocationDescription2.Attributes.Add("onclick", "function")>?
How would this function be written? When the user selects the initial singular record I will need to repopulate the same dropdownlist object with records.
Thank You.
Ayomide