做了一个网页页面,有4个textbox,分别为textbox1, textbox2, textbox3, textbox4;在代码里面循环判断这4个textbox的值;代码如下:
for (int i = 1; i < 4;i++ )
{
if (((TextBox)this.FindControl("TextBox"+i.ToString())).Text.Trim()!="")
{
string sqlstr = "select syr,macaddr,ipaddr,hostname from hh where syr='" + ((TextBox)this.FindControl("TextBox" + i.ToString())).Text + "'";
SqlConnection sqlcon = new SqlConnection("server=.;database=aa;uid=sa;pwd=;");
SqlDataAdapter myda = new SqlDataAdapter(sqlstr, sqlcon);
DataSet myds = new DataSet();
sqlcon.Open();
myda.Fill(myds);
this.GridView1.DataSource = myds;
this.GridView1.DataBind();
sqlcon.Close();
}
else
{
Response.Write("请输入查询内容");
}
错误提示:使用“new”关键字创建对象实例。
初学者,请提示,谢谢
for (int i = 1; i < 4;i++ )
{
if (((TextBox)this.FindControl("TextBox"+i.ToString())).Text.Trim()!="")
{
string sqlstr = "select syr,macaddr,ipaddr,hostname from hh where syr='" + ((TextBox)this.FindControl("TextBox" + i.ToString())).Text + "'";
SqlConnection sqlcon = new SqlConnection("server=.;database=aa;uid=sa;pwd=;");
SqlDataAdapter myda = new SqlDataAdapter(sqlstr, sqlcon);
DataSet myds = new DataSet();
sqlcon.Open();
myda.Fill(myds);
this.GridView1.DataSource = myds;
this.GridView1.DataBind();
sqlcon.Close();
}
else
{
Response.Write("请输入查询内容");
}
错误提示:使用“new”关键字创建对象实例。
初学者,请提示,谢谢
解决方案 »
- 大家好!关于datalist 分页问题,很奇怪!急!
- C#子线程怎么通过事件来更新UI界面,而不使用委托呢?
- cmd 下执行adb 命令 中文 乱码
- **********c#如何检测USB打开消息***************
- 不用保存对话框,用什么方法保存导出的文本文件在默认的路径?
- C#如何实现窗体加载完毕后自动加载数据(类似PB中的PostEvent)
- 北京求职.net开发
- 怎么样使用位运算符 & 请大家给个例子.
- 将lalbel设置为透明,text设置为空 就消失了,怎么找回
- 今天有人对我说……
- Log4net比Console的main()更早运行?
- 如何清除winform Mdi窗体的默认边框?
((TextBox)("testBox"+i.ToString())).Text
有才!哈哈!