我在bm.aspx写下了这语句
<asp:DropDownList runat="server" ID="BM_Dpl_KJDWID" OnFocus='<%#GetDplValue(DropDownList(BM_Dpl_KJDWID),strsql,"bm_kjdwid","kjdw_kjdwmc")%>'/>
他所对应的bm.aspx.cs下的代码如下:
public void GetDplValue(DropDownList Dpl,string StrDpl,string DataValue,string DisValue )
{
OpenDb();
SqlCommand MyComm = new SqlCommand(StrDpl,StrConn);
SqlDataReader MyReader = MyComm.ExecuteReader();
while(MyReader.Read())
{
Dpl.Items.Add(new ListItem(MyReader[DataValue].ToString(),MyReader[DisValue].ToString()));
}
CloseDb();
}
编译的时候出现了如下问题!
CS0119: “System.Web.UI.WebControls.DropDownList”表示“类”,它在给定的上下文中无效
http://localhost/TEST/Bm.aspx(48,118): error CS0119: “System.Web.UI.WebControls.DropDownList”表示“类”,它在给定的上下文中无效
http://localhost/TEST/Bm.aspx(48,146): error CS0103: 名称“strsql”在类或命名空间“ASP.Bm_aspx”中不存在
http://localhost/TEST/Bm.aspx(82,82): error CS1502: 与“System.Convert.ToString(object)”最匹配的重载方法具有一些无效参数
http://localhost/TEST/Bm.aspx(82,106): error CS1503: 参数“1” : 无法从“void”转换为“object”
如果我将GetDplValue(DropDownList(BM_Dpl_KJDWID)改为如下:
<asp:DropDownList runat="server" ID="BM_Dpl_KJDWID" OnFocus='<%#GetDplValue BM_Dpl_KJDWID,strsql,"bm_kjdwid","kjdw_kjdwmc")%>'/>出现如下的错误:
编译器错误信息: CS1502: 与“System.Convert.ToString(object)”最匹配的重载方法具有一些无效参数
http://localhost/TEST/Bm.aspx(48,82): error CS1502: 与“System.Convert.ToString(object)”最匹配的重载方法具有一些无效参数
http://localhost/TEST/Bm.aspx(48,106): error CS1503: 参数“1” : 无法从“void”转换为“object”
http://localhost/TEST/Bm.aspx(82,82): error CS1502: 与“System.Convert.ToString(object)”最匹配的重载方法具有一些无效参数
http://localhost/TEST/Bm.aspx(82,106): error CS1503: 参数“1” : 无法从“void”转换为“object”
<asp:DropDownList runat="server" ID="BM_Dpl_KJDWID" OnFocus='<%#GetDplValue(DropDownList(BM_Dpl_KJDWID),strsql,"bm_kjdwid","kjdw_kjdwmc")%>'/>
他所对应的bm.aspx.cs下的代码如下:
public void GetDplValue(DropDownList Dpl,string StrDpl,string DataValue,string DisValue )
{
OpenDb();
SqlCommand MyComm = new SqlCommand(StrDpl,StrConn);
SqlDataReader MyReader = MyComm.ExecuteReader();
while(MyReader.Read())
{
Dpl.Items.Add(new ListItem(MyReader[DataValue].ToString(),MyReader[DisValue].ToString()));
}
CloseDb();
}
编译的时候出现了如下问题!
CS0119: “System.Web.UI.WebControls.DropDownList”表示“类”,它在给定的上下文中无效
http://localhost/TEST/Bm.aspx(48,118): error CS0119: “System.Web.UI.WebControls.DropDownList”表示“类”,它在给定的上下文中无效
http://localhost/TEST/Bm.aspx(48,146): error CS0103: 名称“strsql”在类或命名空间“ASP.Bm_aspx”中不存在
http://localhost/TEST/Bm.aspx(82,82): error CS1502: 与“System.Convert.ToString(object)”最匹配的重载方法具有一些无效参数
http://localhost/TEST/Bm.aspx(82,106): error CS1503: 参数“1” : 无法从“void”转换为“object”
如果我将GetDplValue(DropDownList(BM_Dpl_KJDWID)改为如下:
<asp:DropDownList runat="server" ID="BM_Dpl_KJDWID" OnFocus='<%#GetDplValue BM_Dpl_KJDWID,strsql,"bm_kjdwid","kjdw_kjdwmc")%>'/>出现如下的错误:
编译器错误信息: CS1502: 与“System.Convert.ToString(object)”最匹配的重载方法具有一些无效参数
http://localhost/TEST/Bm.aspx(48,82): error CS1502: 与“System.Convert.ToString(object)”最匹配的重载方法具有一些无效参数
http://localhost/TEST/Bm.aspx(48,106): error CS1503: 参数“1” : 无法从“void”转换为“object”
http://localhost/TEST/Bm.aspx(82,82): error CS1502: 与“System.Convert.ToString(object)”最匹配的重载方法具有一些无效参数
http://localhost/TEST/Bm.aspx(82,106): error CS1503: 参数“1” : 无法从“void”转换为“object”
解决方案 »
- Repeater嵌套问题,,,真有点难啊??????
- 如何读取数据库某列里不重复的数据,并进行统计
- 请问能把后台得到的datatable绑定到detailsview指定的地方吗?
- 求教关于gridview问题
- 为什么调试的时候老是提示找不到web.config
- 怎样本地化控件中的文字
- 动态创建的按钮button的单击Click事件怎么不执行?
- 如何在datagrid中构建一列为text?
- 关于页面使用ImageButton后,鼠标移动后图片变化和启动事件的求教,在线等急
- 新手的问题--如何更改我的Web 引用(在线)
- asp.net出错了,如何去具体地分类错误类别,然后再分别定向到不同的处理页面?
- 关于运行时自动生成的标题问题,各位请进
为什么一定要把代码嵌入到aspx里面呢......