删除GridView行 [英] deleting gridview row

查看:107
本文介绍了删除GridView行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我想删除griedview中的选定行,并希望在gridview中选择选择按钮时显示该特定记录的详细信息.我想通过C#编码执行所有这些操作.请回复.

Hi all,

I want to delete the selected row in griedview and I want that on selecting the select button in gridview the details of that particular record get displayed. I want to perform all this through coding in C#. Please reply.

推荐答案

由于您正在谈论GridView,因此我将其视为ASP.NET问题.
您需要在GridView中删除并选择CommandField列.

选中此所有GridView [
Since you are talking about GridView, I will consider it as an ASP.NET question.
You need Delete and Select CommandField columns in your GridView.

Check this All-in-one GridView[^] example from CodeProject.

Hope this helps!


string str = GridView1.DataKeys [e.NewSelectedIndex] .Value.ToString();
SqlCommand cmd =新的SqlCommand(从表名中删除,其中id = @ id",con);
cmd.Parameters.AddWithValue("@ id",str);
con.Open();
cmd.ExecuteNonQuery();
con.Close();
string str = GridView1.DataKeys[e.NewSelectedIndex].Value.ToString();
SqlCommand cmd = new SqlCommand("delete from tablename where id=@id", con);
cmd.Parameters.AddWithValue("@id", str);
con.Open();
cmd.ExecuteNonQuery();
con.Close();


这篇关于删除GridView行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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