gridview rowcommand 如何获取当前行的值

xzf_fancy xzf_fancy 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{

if (e.CommandName == "AAA")
{
string a = e.CommandArgument.ToString();
string sql= "select * from abc where id ='" + a + "'";
SqlCommand command = new SqlCommand(sql, Connection);
SqlDataReader Dr = command.ExecuteReader();
while (Dr.Read())
{
a.Text = Dr["a"].ToString();
b.Text = Dr["b"].ToString();
}
Dr.Close();
Connection.Close();
}
}

我现在用的是从数据库读出来的方法,但是效率很差,很慢,能否有方法直接读取呢?
...全文
评论 2
收藏 已收藏
分享
返回顶部
xzf_fancy
C# 111,129 成员 642,538 内容