源代码:
<asp:DataList ID="DataList1" runat="server" BackColor="LightGoldenrodYellow"
BorderColor="Tan" BorderWidth="1px" CellPadding="2" ForeColor="Black"
Height="16px" Width="848px">
<AlternatingItemStyle BackColor="PaleGoldenrod" />
<FooterStyle BackColor="Tan" />
<HeaderStyle BackColor="Tan" Font-Bold="True" />
<SelectedItemStyle BackColor="DarkSlateBlue" ForeColor="GhostWhite" />
<ItemTemplate>
<img src="p_w_picpath/1.jpg" height="40" width="40">
留言者: <%# Eval("username") %>
EMAIL: <%# Eval("email") %>
留言时间: <%# Eval("posttime")%> <asp:LinkButton
ID="LinkButton1" runat="server">回复留言</asp:LinkButton>
<asp:LinkButton ID="LinkButton2" runat="server">删除留言</asp:LinkButton>
<br/><hr/>
留言内容: <%# Eval("contente")%> <br/><hr/>
回复内容: <%# Eval("reply")%> <br/><hr/>
</ItemTemplate>
</asp:DataList>
查看留言界面:
protected void Page_Load(object sender, EventArgs e)
{
string conn = "Data Source=.;Initial Catalog=Information;Integrated Security=True";
SqlConnection con = new SqlConnection(conn);
string sqlstr = "select*from Message";
SqlDataAdapter ad = new SqlDataAdapter(sqlstr,con);
DataSet ds = new DataSet();
con.Open();
ad.Fill(ds);
con.Close();
DataList1.DataSource = ds.Tables[0].DefaultView;
DataList1.DataBind();
}
留言界面:
using System.Data.SqlClient;
using System.Data;
protected void Button2_Click(object sender, EventArgs e)//取消留言
{
TextBox1.Text = "";
TextBox2.Text = "";
TextBox3.Text = "";
}
protected void Button1_Click(object sender, EventArgs e)//发送留言
{
string conn = "Data Source=.;Initial Catalog=Information;Integrated Security=True";
SqlConnection con = new SqlConnection(conn);
string sqlstr = "insert into Message(username,sex,email,contente,p_w_picpathadd)values('" + TextBox1.Text + "','" + RadioButtonList1.SelectedValue + "','" + TextBox2.Text + "','" + TextBox3.Text + "','3.jpg')";
SqlDataAdapter ad = new SqlDataAdapter(sqlstr, con);
DataSet ds = new DataSet();
ad.Fill(ds);
}
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。