我想在点击按钮时从我的数据库中删除一个文件夹。
...
<td><%#Eval("FolderId").ToString() %></td>
...
我使用文件ID列出文件。
这是我的btnDelete代码;
protected void btnDelete_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings[0].ConnectionString);
con.Open();
SqlCommand del = new SqlCommand("delete * from Folders where FolderId=@id");
del.Parameters.AddWithValue("id", ???);
del.ExecuteNonQuery();
con.Close();
}
我应该写什么@id
参数值?
<asp:Repeater ID="rptC" runat="server">
<HeaderTemplate>
<center><table cellpadding="0" cellspacing="0" width="400">
<caption><b>Files</b></caption>
<thead>
<tr>
<th>File ID</th>
<th>Path</th>
<th>?</th>
</tr>
</thead>
</HeaderTemplate>
<ItemTemplate>
<tbody>
<tr>
<td><%#Eval("FolderId").ToString() %></td>
<td><%#Eval("FilePath").ToString() %></td>
<td><asp:Button ID="btnDelete" CssClass="btnH" ForeColor="#ffffff" BackColor="#ba04c2" Text="Delete" runat="server" OnClick="btnDelete_Click"/></td>
</tr>
</tbody>
</ItemTemplate>
<FooterTemplate>
</table> </center>
</FooterTemplate>
</asp:Repeater>