前台代码:
<asp:GridView ID="GridView1" runat="server" CellPadding="4" ForeColor="#333333" GridLines="None" Font-Size="20px" Width="600px">
<AlternatingRowStyle BackColor="White"></AlternatingRowStyle>
<EditRowStyle BackColor="#2461BF"></EditRowStyle>
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White"></FooterStyle>
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" HorizontalAlign="Left"></HeaderStyle>
<PagerStyle HorizontalAlign="Center" BackColor="#2461BF" ForeColor="White" ></PagerStyle>
<RowStyle BackColor="#EFF3FB" Height="30px" HorizontalAlign="Left"></RowStyle>
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333"></SelectedRowStyle>
<SortedAscendingCellStyle BackColor="#F5F7FB"></SortedAscendingCellStyle>
<SortedAscendingHeaderStyle BackColor="#6D95E1"></SortedAscendingHeaderStyle>
<SortedDescendingCellStyle BackColor="#E9EBEF"></SortedDescendingCellStyle>
<SortedDescendingHeaderStyle BackColor="#4870BE"></SortedDescendingHeaderStyle>
</asp:GridView>
后台代码:
string sqlconstr = ConfigurationManager.ConnectionStrings["CS"].ConnectionString;
SqlConnection sqlconn = new SqlConnection(sqlconstr);
SqlCommand command = new SqlCommand();
command.Connection = sqlconn;
sqlconn.Open();
command.CommandText = "SELECT ROW_NUMBER() OVER(ORDER BY o.time DESC) id, o.name,o.price,o.time from [order] o,[User] u where o.uid=u.id";
SqlDataAdapter adapter = new SqlDataAdapter(command);
DataSet dataset = new DataSet();
adapter.Fill(dataset);
if (dataset.Tables[0].Rows.Count > 0){
GridView1.DataSource = dataset;
GridView1.DataBind();
}else{
orderTip.Text = "您没有订单记录~";
//MessageBox.Show("没有相关记录");
}
adapter.Dispose();
dataset.Dispose();
command.Dispose();
sqlconn.Close();
sqlconn.Dispose();
效果:
就是在time后面自动添加一列 内容是删除 然后这个功能要怎么实现?