foreach (ListItem item in this.CheckBoxList1.Items)
{
if (item.Selected==true)
{
if (item.Value==dj)
{
Response.Write("<script>alert('" + kc + "')</script>");
}
}
}只要我加了第2个if 就显示不出来 我这句话没问题吧 大哥们
{
if (item.Selected==true)
{
if (item.Value==dj)
{
Response.Write("<script>alert('" + kc + "')</script>");
}
}
}只要我加了第2个if 就显示不出来 我这句话没问题吧 大哥们
解决方案 »
- 如何把数据库和C#应用程序连接? (有待分析代码)
- 将数据库数据转化为二进制
- 一个正则表达式问题
- C#启动登录窗口时候textbox1就获得焦点怎么做?
- 关于字符串截取问题
- 有谁用过这个函数:ListView_CreateDragImage,知道它属于哪个DLL么?
- 我想用C#写一个截获封包的程序,比如截获所有流经某端口的封包
- 我要怎样才能动态访问当前实例中的属性值?
- 急急急急~~~~~·我想选中datagridview第一列中的一行,并删除,怎么做
- 求个ASP.NET+SQL的网站关于跳绳计数的
- POS E58 小票打印机,重叠打印如何才无效?
- string strName = string.Empty;
string kc;
while (sdr.Read())
{
kc = sdr["课程号"].ToString();
dj = sdr["等级"].ToString();
}
foreach (ListItem item in this.CheckBoxList1.Items)
{
if (item.Selected==true||item.Value==dj)
{
Response.Write("<script>alert('" + kc + "')</script>");
}
}
看下
{
if (item.SelectedValue==dj)
{
Response.Write("<script>alert('" + kc + "')</script>");
}
}
{
Response.Write("<script>alert('" + kc + "')</script>");
}可以直接这么写
{
Response.Write("<script>alert('" + kc + "')</script>");
}
cnnDB.Open();
SqlDataReader sdr = da_bm.ExecuteReader();
string dj;
string kc;
while (sdr.Read())
{
kc = sdr["课程号"].ToString();
dj = sdr["等级"].ToString();
}
foreach (ListItem item in this.CheckBoxList1.Items)
{
if (this.CheckBoxList1.SelectedValue == dj)
{
Response.Write("<script>alert('" + kc + "已经通过考试,请不要连续报名!谢谢')</script>");
}
}
cnnDB.Close();还是不行啊 大哥们
中的dj的值是null,肯定出不来值了。你的先给dj变量赋值。
断点也进不去
不加第2个IF 一切正常
cnnDB.Open();
SqlDataReader sdr = da_bm.ExecuteReader();
string dj;
string kc;
while (sdr.Read())
{
kc = sdr["课程号"].ToString();
dj = sdr["等级"].ToString();
}
foreach (ListItem item in this.CheckBoxList1.Items)
{
if (item.Selected==true)
{
if (item.Value==dj)
{
Response.Write("<script>alert('" + kc + "')</script>");
}
}
}
cnnDB.Close();
事件里的代码 帮忙看下
{
Response.Write(dj); //添加一个测试语句,看看dj的值是什么? if (this.CheckBoxList1.SelectedValue == dj)
{
Response.Write("<script>alert('" + kc + "已经通过考试,请不要连续报名!谢谢')</script>");
}
foreach
只要加 Response.Write(dj);
就什么都不显示了
难道是我的变量问题?
string kc=null;
定义时你先赋值,估计就可以实现了
cnnDB.Open();
SqlDataReader sdr = da_bm.ExecuteReader();
string dj;
string kc;
while (sdr.Read())
{
kc = sdr["课程号"].ToString();
dj = sdr["等级"].ToString();
}
foreach (ListItem item in this.CheckBoxList1.Items)
{
if (item.Selected==true)
{
}
}
cnnDB.Close();我这样写 一点问题没有 下来 加个IF也错 加啥都错 无奈了
SqlCommand da_bm = new SqlCommand("SELECT 课程号,等级 FROM 等级成绩表 WHERE (会考证号 = '" + GridView1.SelectedRow.Cells[1].Text.ToString() + "') and 等级>=3 ", cnnDB);
cnnDB.Open();
SqlDataReader sdr = da_bm.ExecuteReader();
string dj;
string kc;
while (sdr.Read())
{
kc = sdr["课程号"].ToString();
dj = sdr["等级"].ToString();
}
IF(this.CheckBoxList1.SelectedValue==DJ)
{
Response.Write("<script>alert('" + kc + "')</script>");
}
cnnDB.Close();
string dj=null;
string kc=null;
SqlCommand da_bm = new SqlCommand("SELECT 课程号,等级 FROM 等级成绩表 WHERE (会考证号 = '" + GridView1.SelectedRow.Cells[1].Text.ToString() + "') and 等级>=3 ", cnnDB);
cnnDB.Open();
SqlDataReader sdr = da_bm.ExecuteReader();
string dj;
string kc;
while (sdr.Read())
{
kc = sdr["课程号"].ToString();
dj = sdr["等级"].ToString();
}
IF(this.CheckBoxList1.SelectedValue==DJ)
{
Response.Write("<script>alert('" + kc + "')</script>");
}
cnnDB.Close();
cnnDB.Open();
SqlDataReader sdr = da_bm.ExecuteReader();
string dj;
string kc;
while (sdr.Read())
{
kc = sdr["课程号"].ToString();
dj = sdr["等级"].ToString();
}
foreach (ListItem item in this.CheckBoxList1.Items)
{
if (item.Value == dj)
{
Response.Write("<script>alert('" + kc + "')</script>");
}
}
cnnDB.Close();
foreach (ListItem item in this.CheckBoxList1.Items)
{
if (item.Selected==true && item.valeue ==dj)
{
Response.Write("<script>alert('" + kc + "')</script>");
}
}
item.Selected.Value 是object,dj是个string 肯定不等啦,