如何在使用c#点击datalist中的复选框时找到linkbutton值? [英] how to find linkbutton value on clicking checkbox in datalist using c#?
本文介绍了如何在使用c#点击datalist中的复选框时找到linkbutton值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这就是我所做的:
this is what i have done:
<ajaxToolkit:TabContainer ID="TabContainer1" runat="server" ActiveTabIndex="0">
<ajaxToolkit:TabPanel ID="TabPanel1" runat="server" HeaderText="TabPanel1">
<HeaderTemplate>
Pro
</HeaderTemplate>
<ContentTemplate>
<div style="height: 100px; width: 200px; overflow: Auto">
<asp:DataList ID="DataList1" runat="server" CellPadding="2" CellSpacing="2" ForeColor="Red">
<ItemTemplate>
<asp:CheckBox ID="checkbox" runat="server" AutoPostBack="true" OnCheckedChanged="checkLike_CheckedChanged" />
<asp:LinkButton Text='<%#Eval("UPP")%>' ID="lnkpro" runat="server" CssClass="linkbutton"
OnClick="btn_Click" CommandArgument='<%# Eval("UCode") %>'></asp:LinkButton>
</ItemTemplate>
</asp:DataList>
</div>
</ContentTemplate>
</ajaxToolkit:TabPanel>
<ajaxToolkit:TabPanel ID="TabPanel2" runat="server" HeaderText="services">
<HeaderTemplate>
Sets
</HeaderTemplate>
<ContentTemplate>
<div style="height: 100px; width: 200px; overflow: Auto">
<asp:DataList ID="DataList2" runat="server" CellPadding="2" CellSpacing="2">
<ItemTemplate>
<asp:CheckBox ID="checkbox" runat="server" />
<asp:LinkButton Text='<%#Eval("SNA")%>' ID="lnkpro1" runat="server" CssClass="linkbutton"
OnClick="btn_Click1" CommandArgument='<%# Eval("Code") %>'></asp:LinkButton>
</ItemTemplate>
</asp:DataList>
</div>
</ContentTemplate>
</ajaxToolkit:TabPanel>
</ajaxToolkit:TabContainer>
现在我的问题:
此代码块导致所有复选框前面的链接按钮列表。所以我想要的是获取复选框checkchanged上相应的linkbutton值。可能吗?例如
[] linkbtn1
[] linkbtn2
当我在第一个复选框上检查时,应该获取id而不是linkbutton1的文本。([ ]是复选框)
Now my question :
This code block results in a list of link buttons in front of them all checkboxes. So what i want is to get the respective linkbutton value on checkbox checkchanged. Is it possible? for example
[] linkbtn1
[] linkbtn2
when i check on first checkbox the id not text of linkbutton1 should be fetched.([] is checkbox )
推荐答案
你可以使用JQuery来实现这个目的
You can use JQuery for this purpose
( document )。ready(< span class =code-keyword> function (){
(document).ready(function () {
(' #<%= checkbox.ClientID%>')。change( function (){
var optId =
('#<%=checkbox.ClientID %>').change(function () { var optId =
这篇关于如何在使用c#点击datalist中的复选框时找到linkbutton值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文