My code below, does this. When I select a dropdown item from the list, the selected item is appended inside of [dt a span] It lokks like below in Firefox.
VB Code, please could somebody help me get the value of dropdown value selected inside of my vb code.
VB Code, please could somebody help me get the value of dropdown value selected inside of my vb code.
Private Sub ProjectGrid_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles ProjectGrid.ItemCommand
Dim AlternateList As HtmlControls.HtmlGenericControl
'Set the _rId to the Alternate. If that value is zero, then we reset the
AlternateDemonstratorList = e.Item.FindControl("spndropdown")
End Sub
Protected Sub ProjectGrid_ItemDataBound(sender As Object, e As DataGridItemEventArgs)
If e.Item.ItemType = ListItemType.Item Then
Dim spndropdown As HtmlGenericControl = DirectCast(e.Item.FindControl("spndropdown"), HtmlGenericControl)
Dim spndropdownText As String = spndropdown.InnerHtml
spndropdown.InnerHtml = "Select one"
Dim AlternateDropDownList As HtmlGenericControl = DirectCast(e.Item.FindControl("AlternateDropDownList"), HtmlGenericControl)
Dim strAlternateDropDownList As String = AlternateDropDownList.InnerHtml
AlternateDropDownList.InnerHtml = "flag data"
End If
End Sub
Protected Sub ProjectGrid_ItemCommand(source As Object, e As DataGridCommandEventArgs)
If e.Item.ItemType = ListItemType.Item Then
Dim spndropdown As HtmlGenericControl = DirectCast(e.Item.FindControl("spndropdown"), HtmlGenericControl)
Dim AlternateDropDownList As HtmlGenericControl = DirectCast(e.Item.FindControl("AlternateDropDownList"), HtmlGenericControl)
End If
End Sub
Thanks & Regards
Anup Das Gupta
Mark as Answer if you feel so. Visit My Blog
urpalshu
Member
50 Points
254 Posts
VB Code, please could somebody help me get the value of dropdown value selected inside of my vb c...
Apr 03, 2012 06:49 PM|LINK
Hello:
My code below, does this. When I select a dropdown item from the list, the selected item is appended inside of [dt a span] It lokks like below in Firefox.
VB Code, please could somebody help me get the value of dropdown value selected inside of my vb code.
My JavaScript Code
$(document).ready(function() { $(".dropdown dt a").click(function(event) { event.preventDefault(); $(this).closest("dl").find("ul").toggle(); }); $(document).bind('click', function(e) { var $clicked = $(e.target); if (!$clicked.parents().hasClass("dropdown")) $(".dropdown dd ul").hide(); }); $(".dropdown dd ul li a").click(function() { if ($(this).parent().is("dt")) { $(this).closest("dl").find("dd").toggle(); } else { var drop = $(this).closest("dl"); drop.find("dt").empty().append($(this).clone()) $(".dropdown dd ul").hide(); } }); });My css code
body { font-family:Arial, Helvetica, Sans-Serif; font-size:0.75em; color:#000;} .desc { color:#6b6b6b;} .desc a {color:#030303;} .dropdown dd, .dropdown dt, .dropdown ul { margin:1px; padding:1px; } .dropdown dd { position:absolute; width:200px;font-size: 8pt;color: black;font-family: Verdana, Arial;height: 21px;} .dropdown a, .dropdown a:visited { color:#030303; text-decoration:none; outline:none;} .dropdown a:hover { color: #030303;} .dropdown dt a:hover { color: #030303; border: 1px solid #030303;} .dropdown dt a {background: url(../Images/arrow.gif) no-repeat scroll right center; display:block; padding-right:20px; border:1px solid #00539F; width:200px;} .dropdown dt a span {cursor:pointer; display:block; padding:5px; background-image:#FFFFFF url(../Images/arrow.gif) no-repeat scroll right center; display:block; padding-right:20px; color:#030303;} .dropdown dd ul { background:#FFFFFF none repeat scroll 0 0; border:1px solid #030303; color:#030303; display:none; left:0px; padding:5px 0px; position:absolute; top:2px; width:200px; list-style:none;} .dropdown span.value { display:none;} .dropdown dd ul li a { padding:1px; display:block; color:#030303;} .dropdown dd ul li a:hover { background-color:#00539F; color:#FFFFFF;} .dropdown img.flag { border:none; vertical-align:middle; margin-left:10px; } .flagvisibility { display:none;}My DataGrid
<div style="overflow-y: scroll; width: 900px; height: 200px"> <asp:DataGrid ID="ProjectGrid" runat="server" AutoGenerateColumns="False" CellPadding="0" CssClass="DataTable" Width="883px"> <HeaderStyle Font-Bold="True" /> <Columns> <asp:TemplateColumn HeaderText="Alternate"> <HeaderStyle Width="200px" Font-Bold="True" CssClass="DataCol" /> <ItemStyle Width="200px" CssClass="DataCol" /> <ItemTemplate> <dl id="sample" class="dropdown"> <dt runat="server" id="spndropdown"><a href="#"><span >Please select </span></a></dt> <dd class="DataCol" > <ul runat="server" id="AlternateDropDownList"> <li><a href="#">Brazil<img class="flag" src="br.png" alt="" /><span class="value">BR</span></a></li> <li><a href="#">France<img class="flag" src="fr.png" alt="" /><span class="value">FR</span></a></li> <li><a href="#">Germany<img class="flag" src="de.png" alt="" /><span class="value">DE</span></a></li> </ul> </dd> </dl> <asp:HiddenField runat="server" ID="hfAlternate"/> </ItemTemplate> </asp:TemplateColumn> </Columns> </asp:DataGrid>> </div>VB Code, please could somebody help me get the value of dropdown value selected inside of my vb code.
Private Sub ProjectGrid_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles ProjectGrid.ItemCommand Dim AlternateList As HtmlControls.HtmlGenericControl 'Set the _rId to the Alternate. If that value is zero, then we reset the AlternateDemonstratorList = e.Item.FindControl("spndropdown") End SubThank you,
rickjames961
Participant
775 Points
174 Posts
Re: VB Code, please could somebody help me get the value of dropdown value selected inside of my ...
Apr 03, 2012 09:17 PM|LINK
havent used VB in some time but heres my attempt
Dim myDropdown as DropDownList
myDropdown =(DropDownList)(e.Item.FindControl("spndropdown"))
or this
Dim myDropdown As DropDownList = CType(e.Item.FindControl("spndropdown"), DropDownList)
Friedrich Nietzsche
asteranup
All-Star
30184 Points
4906 Posts
Re: VB Code, please could somebody help me get the value of dropdown value selected inside of my ...
Apr 04, 2012 04:45 AM|LINK
Hi,
Try this code-
Protected Sub ProjectGrid_ItemDataBound(sender As Object, e As DataGridItemEventArgs) If e.Item.ItemType = ListItemType.Item Then Dim spndropdown As HtmlGenericControl = DirectCast(e.Item.FindControl("spndropdown"), HtmlGenericControl) Dim spndropdownText As String = spndropdown.InnerHtml spndropdown.InnerHtml = "Select one" Dim AlternateDropDownList As HtmlGenericControl = DirectCast(e.Item.FindControl("AlternateDropDownList"), HtmlGenericControl) Dim strAlternateDropDownList As String = AlternateDropDownList.InnerHtml AlternateDropDownList.InnerHtml = "flag data" End If End Sub Protected Sub ProjectGrid_ItemCommand(source As Object, e As DataGridCommandEventArgs) If e.Item.ItemType = ListItemType.Item Then Dim spndropdown As HtmlGenericControl = DirectCast(e.Item.FindControl("spndropdown"), HtmlGenericControl) Dim AlternateDropDownList As HtmlGenericControl = DirectCast(e.Item.FindControl("AlternateDropDownList"), HtmlGenericControl) End If End SubAnup Das Gupta
Mark as Answer if you feel so. Visit My Blog
urpalshu
Member
50 Points
254 Posts
Re: VB Code, please could somebody help me get the value of dropdown value selected inside of my ...
Apr 04, 2012 12:53 PM|LINK
Thank you very much for your suggestions. I am looking for the value of the selected item from the drop down list.
Your code above inside the ItemCommand AlternateDropDownList is = nothing
spndropdown value is= "Please Select"
I am unable to grab the selected value on code behind.
Thank you,