protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
SqlConnection conn = SqlConnection("str");//str为连接字符串
SqlCommand comm = new SqlCommand();
comm.Connection = conn;
comm.CommandType = CommandType.Text;
comm.CommandText = "Select * From tb_promble Where title like '%" +this.tb_ggjz.Text.ToString()+" %'";
conn.Open();
SqlDataAdapter sda = new SqlDataAdapter(comm);
sda.SelectCommand = comm;
DataSet ds = new DataSet();
sda.Fill(ds);
this.DataList1.DataSource = ds.Tables["tb_promble"].DefaultView;
//this.DataList1.DataKeyField = "ID";
this.DataList1.DataBind();
sda.Dispose();
ds.Dispose();
comm.Dispose();
conn.Close();
}
出现错误:
this.DataList1.DataSource = ds.Tables["tb_promble"].DefaultView;
未将对象引用设置到对象实例!
各位帮帮,忙呀 谢谢
{
SqlConnection conn = SqlConnection("str");//str为连接字符串
SqlCommand comm = new SqlCommand();
comm.Connection = conn;
comm.CommandType = CommandType.Text;
comm.CommandText = "Select * From tb_promble Where title like '%" +this.tb_ggjz.Text.ToString()+" %'";
conn.Open();
SqlDataAdapter sda = new SqlDataAdapter(comm);
sda.SelectCommand = comm;
DataSet ds = new DataSet();
sda.Fill(ds);
this.DataList1.DataSource = ds.Tables["tb_promble"].DefaultView;
//this.DataList1.DataKeyField = "ID";
this.DataList1.DataBind();
sda.Dispose();
ds.Dispose();
comm.Dispose();
conn.Close();
}
出现错误:
this.DataList1.DataSource = ds.Tables["tb_promble"].DefaultView;
未将对象引用设置到对象实例!
各位帮帮,忙呀 谢谢
解决方案 »
- 如何实现类似工具栏这样的功能
- 事务执行的问题
- 用ASP.NET做这样的编辑器(图标设计、名片设计)主要知识点是什么?
- 查找RadComboBox的ItemTemplate中的控制,总提示索引超出范围
- asp:LinkButton
- 技术确实 重要 吗?
- .NET的组件使用问题
- .net 2005中 如何套用 javascript 脚本
- Context.User的默认类型为System.Security.Principal.GenericPrincipal??
- 如何弹出新窗口同时使它最小化或者隐藏。
- 紧急求救啊。。关于VS2010 制作网页 但浏览器打不开的问题。
- asp.net image控件如何控制图片大小
改成
sda.Fill(ds,"tb_promble");
改为this.DataList1.DataSource = ds.Tables[0].DefaultView;