如图,我用datalist来显示留言聚居,datalist里面有个linkbutton控件,并且加了ondeletecommand,执行以下过程
这个过程我不知道要怎么改,还有,怎么才能删除对应ID的留言,ID是主键
<script runat="server">
Sub Data_del ( s as object, e as DatalistCommandEventargs )
Dim OleConn as OleDbConnection
Dim OleCmd as OleDbCommand
Dim OleDel as string
OleConn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;DataSource=h:\web\data\webdata.mdb;User ID=;Password=")
OleDel = "Delete MessageBook where ID = '?'"
OleCmd = new OleDbCommand ( OleDel, OleConn )
OleConn.open
OleCmd.ExecuteNonQuery()
OleConn.close
end sub
</script>
这个是datalist
<asp:DataList id="DataList1"
runat="server"
RepeatColumns="1"
RepeatDirection="Vertical"
OnDeleteCommand="Data_del"
RepeatLayout="Flow"
DataSource="<%# Message.DefaultView %>" >
<ItemTemplate>
<table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#CDCDB8">
<tr>
<td colspan="4" bgcolor="#d3d3be"> </td>
</tr>
<tr>
<td height="25" colspan="4" bgcolor="#F3F3ED"><table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="34%" align="left" class="font_color"> □留言序号 <%# Message.FieldValue("ID", Container) %></td>
<td width="29%"><a href="123" class="font_color">QQ联系</a></td>
<td class="font_color"><%# Message.FieldValue("Time", Container) %></td>
</tr>
</table></td>
</tr>
<tr>
<td width="118" bgcolor="edede4"><table width="100%" height="125" border="0" cellpadding="0" cellspacing="1" bgcolor="#CDCDB8">
<tr>
<td height="110" align="center" valign="middle" bgcolor="edede4"><img src="face/<%# Message.FieldValue("Face", Container) %>.jpg" width="100" height="100" /></td>
</tr>
<tr>
<td align="center" bgcolor="edede4" class="font_color"><%# Message.FieldValue("Name", Container) %></td>
</tr>
</table></td>
<td colspan="3" valign="top" bgcolor="#F3F3ED"><table width="100%" height="125" border="0" cellpadding="5" cellspacing="0">
<tr>
<td align="left" valign="top" class="font_color"><img src="<%# Message.FieldValue("Miange", Container) %>" width="45" height="45" /><%# Message.FieldValue("Book", Container) %></td>
</tr>
</table></td>
</tr>
<tr>
<td height="13" colspan="2" valign="bottom" bgcolor="#F3F3ED"> </td>
<td width="73" height="13" valign="bottom" bgcolor="#F3F3ED"> </td>
<td width="72" height="15" valign="bottom" bgcolor="#F3F3ED" class="font_color"><asp:LinkButton CommandName="delete" CssClass="font_color" ID="Del" runat="server" text="删除"></asp:LinkButton></td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>