在ASP.NET中用于更新运行时数据库的交互式表 [英] Interactive Table for runtime database updation in asp.net

查看:106
本文介绍了在ASP.NET中用于更新运行时数据库的交互式表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我必须设计一个页面,其中数据库条目列表将显示为带有某些复选框的表(普通html表或gridview或其他内容).用户应该能够从这些复选框中选择一些选项,并且一旦发布数据库,选定的值就应该更新到数据库中.我是asp.net和C#的新手.

举个例子.
考虑一个考勤管理系统,其中候选者在带有复选框的表中列出,该复选框使一个人可以选择一个人在场或不在,并且该人单击一个更新按钮,该按钮将考勤数据发布到数据库中.

在此先感谢

Hi all,
I have to design a page in which a list of entries from a database are to be displayed as a table(either normal html table or maybe gridview or something.) with some checkboxes in it. The user should be able to select some options from these checkboxes and the selected value shud be updated to the database once when it is posted. I''m new to asp.net and c#.

As an example.
Consider an attendance mgmt system wherein the candidates are listed in a table with checkboxes that enables a person to select whether a person is present or absent and the person clicks an update button which posts that attendance data to a database.

Thanks in advance

推荐答案



请按照以下步骤操作...

1.将带有复选框的项目模板列添加到gridview.

2.启用CheckBox的AutoPostBack

3.处理复选框的OnCheckedChangedEvent.

在函数中编写以下代码.

CheckBox objCheck = sender作为CheckBox;

GridViewRow objRow = objCheck.NamingContainer作为GridViewRow;

GridViewRow objSelectedRow = GridView1.Rows [objRow.Index];

//在这里,您可以从选定行"的单元格中提取值.

字符串strName = objSelectedRow.Cells [1]; //假设Cell [1]包含名称

//然后可以触发更新查询以更新数据.

问候,
RK
Hi,

Follow the steps below...

1. Add an item template columns with a checkbox to gridview.

2. Enable AutoPostBack of CheckBox

3. Handle the OnCheckedChangedEvent for Checkbox.

in the function write the following code.

CheckBox objCheck=sender as CheckBox;

GridViewRow objRow=objCheck.NamingContainer as GridViewRow;

GridViewRow objSelectedRow=GridView1.Rows[objRow.Index];

// Here you can extract the values from the cells of the Selected Row.

string strName=objSelectedRow.Cells[1]; // assuming that Cell[1] contains the name

// The Update Query can be then fired to update the data.

Regards,
RK


这篇关于在ASP.NET中用于更新运行时数据库的交互式表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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