本人渣渣一枚 还请各位指点
废话不多说贴上部分源代码
前台部分 repeater控件显示留言内容
<asp:Repeater ID="rep" runat="server" OnItemCommand="rep_ItemCommand" >
<ItemTemplate>
<hr class="hr1"/>
<div id="usname">
<%#Eval("UserName") %>
</div>
<div id="words">
<table>
<tr>
<td>
<%#Eval("Words") %>
</td>
</tr>
</table>
<p class="p1">
<span>
<%#Eval("DATE") %>
</span>
<asp:LinkButton ID="rbutton" runat="server" Text="回复"></asp:LinkButton>
<asp:LinkButton ID="dbutton" runat="server" Text="删除" CommandArgument='<%#Eval("ID") %>'></asp:LinkButton>
</p>
</div>
</ItemTemplate>
</asp:Repeater>
后台部分 dbutton按钮出发事件的函数
protected void dbutton_Click(object sender, EventArgs e)
{
int i = Convert.ToInt32(((LinkButton)sender).CommandArgument);
SqlConnection con2 = new SqlConnection("Data Source=.;Initial Catalog=UserInfo;Integrated Security=True");
SqlCommand comm1 = new SqlCommand("delete from userwords where ID=" + i + "", con2);
con2.Open();
comm1.ExecuteNonQuery();
con2.Close();
}
为什么就是删除不了数据库里面的一条记录 CommandArgument传递过来的参数是什么类型的。