本文介绍了“字符串"不包含“已检查"的定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在C#代码的定义中遇到问题
i have problem in definition in c# code
protected void Button1_Click(object sender, EventArgs e)
{
foreach (GridViewRow row in GridView1.Rows)
{
string chk = (row.FindControl("chkdelete") as CheckBox).Text;
if (chk.Checked)
{
string lblid = (row.FindControl("lblid") as Label).Text;
SqlCommand comm =new SqlCommand();
comm.CommandText = "delete from tbluser where id=@id";
comm.Connection = conn;
comm.Parameters.AddWithValue("@id",int.Parse(lblid.ToString()));
conn.Open();
comm.ExecuteNonQuery();
conn.Close();
}
}
LoadGridView();
}
帮助我解决该错误的错误:-是
help me to solve this error the error:- is
Error 1 'string' does not contain a definition for 'Checked' C:\Documents and Settings\Harry\My Documents\Visual Studio 2005\deleting data from grid view\Default.aspx.cs 39 21 C:\...\deleting data from grid view\
谢谢你.
thank you
推荐答案
CheckBox chk = row.FindControl("chkdelete") As CheckBox;
if (chk != null)
{
if (chk.Checked)
{
// do something
}
}
CheckBox chk = ((CheckBox)(row.FindControl("chkdelete")));
if (chk.Checked)
{
....
}
这篇关于“字符串"不包含“已检查"的定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!