从asp.net更新和删除ms sql server数据库的多条记录 [英] Updating and deleting multiple records of ms sql server database from asp.net

查看:126
本文介绍了从asp.net更新和删除ms sql server数据库的多条记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I am developing an social application on Asp.net with MS SQL Server 2012 as the database.
I want to display user Their All Updates/Tweets Messages on Webpage and then from this Web page user can Delete or Update any Tweet Messages.

I have user Text boxes to display the most 10 recent Tweet Messages on the Web Page. and also gives a update or delete button with every text field. But I am thinking that by this technique i have to write lot of code of have to map which button is associated with what text field.

I need to know that is there any other better technique to achieve this task.

推荐答案

使用GridView ,参考:使用Gridview插入,更新,删除......简单方法 [ ^ ]
Use GridView, refer: Insert, Update, Delete with Gridview ... Simple Way[^]


您可以简单地将多个按钮的点击事件关联到单个处理程序,如下所示:



You can simply associate multiple button's click event to a single handler like so:

public partial class MyPage: System.Web.UI.Page
{
    UpdateButton1.OnClick += Update_Click;
    UpdateButton2.OnClick += Update_Click;
    UpdateButton3.OnClick += Update_Click;

    private void Update_Click(Object sender, EventArgs e)
    {
        //Your data update code here.
    }
}


这篇关于从asp.net更新和删除ms sql server数据库的多条记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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