怎么样在DataList控件中使用删除???????????
求助,如何在datalist控件中使用删除我想在这个基础上增加删除功能
a.aspx页面的关键代码:
<asp:datalist id="DataList1" runat="server" width="700px" CellPadding="4" ForeColor="#333333">
<FooterStyle ForeColor="White" Font-Bold="True" BackColor="#507CD1"></FooterStyle>
<SelectedItemStyle BackColor="#D1DDF1" ForeColor="#333333" Font-Bold="True">< lectedItemStyle>
<ItemTemplate>
<table style="width: 700">
<tr>
<td style="width: 10px; height:2px"></td>
<td style="width: 400px; height:2px"><a href="stushow.aspx?id=<%# Eval("id")%>" target=mainFrame><asp:Label id="Label2" runat="server" Text='<%# Eval("title") %>'></asp:Label></a></td>
<td style="width: 70px; height:2px"><a href="student.aspx?id=<%# Eval("studentID")%>" target=mainFrame><asp:Label id="Label3" runat="server" Text='<%# Eval("studentID") %>'></asp:Label></td>
<td align="right" style="width: 80px; height:2px"><asp:Label id="Label4" runat="server" Text='<%# Eval("creattime") %>'></asp:Label></td>
</tr>
</table>
</ItemTemplate>
<AlternatingItemStyle BackColor="White"></AlternatingItemStyle>
<ItemStyle BackColor="#EFF3FB"></ItemStyle>
<HeaderStyle BackColor="#507CD1" ForeColor="White" Font-Bold="True"></HeaderStyle>
</asp:datalist>
a.aspx.cs页面中的关键代码:
public partial class stustudy1: System.Web.UI.Page
{
SqlConnection sms_conn;
protected void Page_Load(object sender, EventArgs e)
{
string sms_connstr = System.Configuration.ConfigurationManager.AppSettings["sms_dbconn"];
// 建立连接
sms_conn = new SqlConnection(sms_connstr);
if (!IsPostBack)
dataListBind();
}
private void dataListBind() //绑定文件
{
sms_conn.Open();
string sms_sqlstr = "select id,title,content,type,type1,studentID,convert(varchar(12),creattime,102) as creattime from writeshow where type=5 and type1=1";
SqlDataAdapter sms_adp = new SqlDataAdapter(sms_sqlstr, sms_conn);
DataSet sms_ds = new DataSet();
sms_adp.Fill(sms_ds);
sms_conn.Close();
DataList1.DataSource = sms_ds;
DataList1.DataBind();
sms_ds.Clear();
sms_ds.Dispose();
}
}
谢谢!