如何在GridView中选择复选框 [英] How to Select Checkbox in GridView
本文介绍了如何在GridView中选择复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我用一组图像绑定Gridview,我想要...如果我将点击图像然后自动检查correspoinding复选框,如果已经选中复选框,那么它将被取消选中。
< br $>
http://i.imgur.com/FLuwEae.png
< asp:DataList ID = DataList1 runat = server < span class =code-attribute> RepeatColumns = 4 RepeatDirection = 水平 >
< ItemTemplate >
< asp:Panel ID = Panel1 runat = server < span class =code-attribute> BorderColor = #FF9933 BorderWidth = 3px 高度 = < span class =code-keyword> 200px 宽度 = 300px >
< 表 宽度 = 100% > ;
< tr >
< td width = 75% 样式 = 颜色:#FF0000; font-weight:bold align = center >
< div class = images >
< img src =' < ;% #Eval( ThumbfileLink)%>' < span class =code-attribute> height = 170px width = 270px / >
< / div > ;
< / td >
< / tr >
< tr >
< td width = 25% style = 颜色:#FF0000; font-weight:bold align = center >
< asp:CheckBox ID = CheckBox1 < span class =code-attribute> runat = server >
< / asp:CheckBox > <% #Eval( 宽度)%> X <% #Eval( Height跨度>)%>
< / td >
< / tr >
< / table >
< / asp:Panel >
< / ItemTemplate >
< / asp:DataList >
如何要做到这一点
谢谢
解决方案
让我们尝试使用jQuery来实现这个目标:
将jquery代码添加到head部分:
< head id = Head1 runat = 服务器 >
< script 类型 = text / javascript src = http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/ jquery.min.js > < / script >
< script type = text / javascript >
(文件).ready(function(){
(。Image1)。click(function(){
//遍历你当前的表结构
var
I binded Gridview with set of images and i want that.. if I will Click on image then correspoinding checkbox will be checked automatically and if checkbox is already checked then it will be unchecked.
http://i.imgur.com/FLuwEae.png
<asp:DataList ID="DataList1" runat="server" RepeatColumns="4" RepeatDirection="Horizontal" >
<ItemTemplate>
<asp:Panel ID="Panel1" runat="server" BorderColor="#FF9933" BorderWidth="3px" Height="200px" Width="300px">
<table width="100%">
<tr>
<td width="75%" style="color: #FF0000; font-weight: bold" align="center">
<div class="images">
<img src='<%#Eval("ThumbfileLink") %>' height="170px" width="270px" />
</div>
</td>
</tr>
<tr>
<td width="25%" style="color: #FF0000; font-weight: bold" align="center">
<asp:CheckBox ID="CheckBox1" runat="server">
</asp:CheckBox> <%#Eval("Width")%> X <%#Eval("Height")%>
</td>
</tr>
</table>
</asp:Panel>
</ItemTemplate>
</asp:DataList>
How to do this
Thanks
解决方案
Let try to use jQuery to achieve this:
add the jquery code to the head section:
<head id="Head1" runat="server"> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> <script type="text/javascript">
(document).ready(function () {
(".Image1").click(function () { // traversing your current table structure var
这篇关于如何在GridView中选择复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文