gridview问题中的复选框 [英] checkbox in gridview problem

查看:92
本文介绍了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问题中的复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆