各位帮我看看,这问题出在哪?
protected void bindRepeater()
{
SqlConnection conn = dataoperate.createcon();
SqlDataAdapter sda = new SqlDataAdapter("select * from CA_ClassParam order by code", conn);
DataSet ds = new DataSet();
sda.Fill(ds);
if (ds.Tables[0].Rows.Count > 0)
{
this.repClassParam.DataSource = ds.Tables[0].DefaultView;
this.repClassParam.DataBind();
}
for (int i = 0; i < this.repClassParam.Items.Count; i++)
{
Label bid = (Label)this.repClassParam.Items[i].FindControl("lblBigClassID");
int id=Convert.ToInt32(bid.Text);
Repeater rep = (Repeater)this.repClassParam.Items[i].FindControl("repChild");
SqlDataAdapter sda2 = new SqlDataAdapter("select * from CA_Paramebase where ClassID=" + id, conn);
DataSet ds2 = new DataSet();
sda2.Fill(ds2);
rep.DataSource = ds2;
rep.DataBind();
}
}
这是二个嵌套Repeater,这样绑定为什么出现错误???
int id=Convert.ToInt32(bid.Text);未将对象引用设置到对象的实例
我前台的父Repeater的ItemTemplate项里放了一个<asp:Label ID="lblBigClassID" Text=<%# Eval("ID") %> runat=server></asp:Label>