Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have a datalist with link button inside it which is binded with some values... I want to know how to return the value of selected item inside the datalist using javascript...

ASP.NET
<asp:DataList ID="dlstZone" runat="server" CellPadding="3" CssClass="dlist_css" RepeatColumns="4" RepeatDirection="Horizontal">
  <ItemTemplate>
    <div style="margin:2px;padding:2px;float:left;width:50%;">
     <asp:LinkButton ForeColor="Blue" Font-Underline="true" ID="lbtnZone"
     runat="server" Text='<%#Eval("zName")%>' CommandName="select"
     CommandArgument='<%#Eval("zName")%>'> </asp:LinkButton>
    </div>
  </ItemTemplate>
<SeparatorTemplate>
<h4 class="row_seperator"></h4>
</SeparatorTemplate>
</asp:DataList>
Posted
Comments
Sinisa Hajnal 4-Dec-15 5:54am    
Why do you need this? If you need client side checks, why use server side controls?
If you really need it, use Developer tools to see exactly what renders on your page and find the value you need like this:
$("#<%=dlstZone.CliendID %> a:active") or maybe :selected or, if it isn't a but input[type="checkbox"] etc...
SajinAboo 4-Dec-15 5:57am    
Because its an existing work and I can't change the layout... i can only develop a chart based on this data list click... i have already built a chart using a radio button list yesterday, now I have another chart which is formed from a datalist click...
Sinisa Hajnal 4-Dec-15 7:14am    
Well, the same logic applies. Same way you grabbed radio button value, you can grab datalist value, selector will depend on particular element, but the basic grab is the same.

If you can alter itemtemplate you could use OnClientClick property to call javascript function to do what you need to do. Don't forget to return false if you don't want default handler to trigger

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900