我在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”