【发布时间】:2020-02-13 21:08:35
【问题描述】:
我的代码中有这个功能
protected void ShowDocument(int id, object sender, EventArgs e)
{
byte[] bytes;
string constr = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
using (SqlConnection con = new SqlConnection(constr))
{
con.Open();
using (SqlCommand com = new SqlCommand("SELECT Data FROM FileUploader2", con))
{
using (SqlDataReader reader = com.ExecuteReader())
{
if (reader.Read())
{
bytes = (byte[])reader["Data"];
}
}
}
}
}
我在我的 aspx 上调用它如下:
<input type="button" ID="btnView" runat="server" value="View"
onserverclick="ShowDocument(id)" />
但它给了我一个错误,说名称 id 在当前上下文中不存在。我究竟做错了什么? 如果我只是写 ShowDocument 那么
“ShowDocument”没有重载匹配委托“System.EventHandler”
【问题讨论】:
-
你的 'id' 在 aspx 文件中在哪里?它存在吗?