本来在做一个简单的数据绑定页面时,到处都有绑定,后来自己写了2个公共的方法来绑定datagrid:
private void dgTableDataBind(string dydm, string qsny, string zzny)
{
string sqlSelect = "select dydm dm, kgsdm2mc(dydm) dydm, ny, decode(passed,1,'是','否') passed from yjbg_zb_yyfx_dxjy where ny between :qsny and :zzny and dydm like :dydm order by ny desc";
this.cmd.CommandText = sqlSelect;
this.cmd.Parameters.Add("qsny",OracleType.VarChar,6).Value = qsny;
this.cmd.Parameters.Add("zzny",OracleType.VarChar,6).Value = zzny;
this.cmd.Parameters.Add("dydm",OracleType.VarChar,4).Value = dydm;
this.cmd.CommandType = CommandType.Text;
this.cmd.Connection = this.con;
this.adp.SelectCommand = this.cmd;
try
{
this.adp.Fill(this.ds, "dgTable");
}
catch(Exception ex)
{
this.lblTabelMsg.Text += ex.Message + "<br>";
return;
}
this.dgTable.DataSource = this.ds;
this.dgTable.DataMember = "dgTable";
this.dgTable.DataBind();
}private void dgTableDataBind()
{
string dydm = this.ddlDW.SelectedItem.Value;
string qsny = this.hdQSNY.Value;
string zzny = this.hdZZNY.Value;
this.dgTableDataBind(dydm, qsny, zzny);
}
可是问题就出现了,在
this.adp.Fill(this.ds, "dgTable");
行老 是出现”ORA-01036: 非法的变量名/编号“错误,而且页面第一次请求时不出,我点上面的编辑等linkbutton时才出。
我在页面的绑定如下:
<asp:TemplateColumn HeaderText="单位">
<ItemTemplate>
<asp:Label id=lblDW runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "dydm") %>'>
</asp:Label>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="年月">
<ItemTemplate>
<asp:Label id=lblNY runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "ny") %>'>
</asp:Label>
</ItemTemplate>
</asp:TemplateColumn>在网上查了一下,碰到这个问题的不少,但是都没有找到答案。
望高手解答。