gridview问题中的复选框

编程入门 行业动态 更新时间:2024-10-27 05:32:24
本文介绍了gridview问题中的复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有gridview,在gridview内有一个汇整列复选框.现在,我要检查复选框是否已选中,然后更新数据库.现在,我无法编写我在其中编写代码的gridview事件的代码.请帮助我

I have gridview, inside gridview a take column checkbox. Now I want if checkbox is checked then update database. Now I am not able to write code in which gridview event I write code.Please help me

推荐答案

您必须使用复选框的OnCheckChanged事件. > 在该事件的来源中,您声明: You have to use the OnCheckChanged Event of the checkbox. In the source of that event you state: CheckBox cb = (CheckBox)sender; GridViewRow row =(GridViewRow)cb.NamingContainer;

在这种情况下,您不知道复选框在哪一行中.现在,您知道复选框和行,因此,如果将selectedindex设置到该行(row.RowIndex),并在gridview设置中使用DataNames,就知道数据库中要更新的内容

In that case you kno in which row the checkbox was check3ed. You now know checkbox and teh row, so if you set the selectedindex to that row (row.RowIndex) and you use the DataNames in the gridview settings, you know what to update in your database

您可以通过以下方式实现此目标: 1.添加处理程序以调用服务器端函数(checkFunction),在其中编写用于数据库连接和查询执行的代码. 添加处理程序的代码 AddHandler CheckBox1.CheckedChanged AddressOf checkFunction 在checkFunction中为更新记录编写数据库代码.在此,您选中了复选框ID. 一切顺利. You can achieve this in following way: 1. add handler to call server side function(checkFunction) in which you write your code for database connection and query execution. code for add handler AddHandler CheckBox1.CheckedChanged AddressOf checkFunction in checkFunction write database code for update records.in this you got checked checkbox id. All the best.

更多推荐

gridview问题中的复选框

本文发布于:2023-11-07 09:03:31,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1566050.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:复选框   gridview

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!