用的CheckedChanged事件添加复选框,以动态的GridView [英] Add checkbox with CheckedChanged Event to a Dynamic GridView

查看:275
本文介绍了用的CheckedChanged事件添加复选框,以动态的GridView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想动态复选框与事件一起添加到动态的GridView。

I want to dynamically add a checkbox to a dynamic GridView along with an Event.

即。网格我要补充复选框根据数据库中动态选中或取消选中。并通过点击复选框,本身我想更新数据库。

i.e. For the grid I have to add check boxes dynamically checked or unchecked according to the Database. And by clicking the checkbox itself I want to update the database.

为此,我需要该事件也与复选框一起动态加载。

For this I need the Event to also be dynamically loaded along with the checkbox.

我已经完成了一个静态的版本,这里展出:

What I have completed is a static version and is exhibited here:

在数据库角色ID(管理员,采购总监等),ActivityID(离开应用程序等)和OperationID(保存,编辑等)的存储位置。

In database RoleID(Admin,Purchase Officer etc), ActivityID(Leave application etc) and OperationID(Save,Edit Etc) are stored.

第一行意味着管理员(角色ID 1)保存操作(OperationID 1)允许的活动休假应用(Activityid 3)。

First row implies for Admin(roleid 1) Save operation(OperationID 1) is allowed for activity Leave application(Activityid 3).

推荐答案

如果您要添加在运行时复选框,当您添加复选框,复选框事件需要加以界定。

if you are adding checkboxes at runtime, when you add checkbox, the checkbox event needs to be defined.

例如:

    TableCell tcCheckCell = new TableCell();
    var checkBox = new CheckBox();
    checkBox.CheckedChanged += checkBox_CheckedChanged;
    tcCheckCell.Controls.Add(checkBox);
    gridView.Rows[0].Cells.AddAt(0, tcCheckCell);

    void checkBox_CheckedChanged(object sender, EventArgs e)
    {
        //do something: You can use Krishna Thota's Code.
    }

这篇关于用的CheckedChanged事件添加复选框,以动态的GridView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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