每次添加数据时,程序就会出问题,高手帮忙看看下面代码...
我已经发现问题了
每次选择了这几个ID的复选框,当这个时候有新添加信息之后,ID就变了,变成选择其它ID的复选框了,这时的操作就出现了问题
如果这时没有新信息添加的时候,ID就不会变,操作也不会出现问题
我该如何解决
protected void Btn_Do_Click(object sender, EventArgs e)
{
string keyValues = " ";
for (int i = 0; i < Repeater.Items.Count; i++)
{
CheckBox chkbox = (CheckBox)Repeater.Items[i].FindControl( "op ");
if (chkbox!=null)
{
if (chkbox.Checked == true)
{
string key = ((Label)Repeater.Items[i].Controls[2]).Text + ", ";
keyValues = keyValues + key;
}
}
}
if (keyValues != " ")
{
keyValues = keyValues.Substring(0, keyValues.Length - 1);
SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings[ "sqlcon "]);
con.Open();
string nowtime = DateTime.Now.ToString();
string op = ddl_op.Text.ToString();
string cmdsql = " ";
if (op == "del ")
{
cmdsql= "delete from " + tablename +