日期:2014-05-18 浏览次数:20367 次
DataTable dt = DB.GetAllLines(Int32.Parse(lblGameID.Text)); gv.DataSource = dt; gv.DataBind();
<asp:GridView ID="gv" runat="server" AutoGenerateDeleteButton="True" BorderColor="#99FF99" BorderStyle="Solid" BorderWidth="1px" EmptyDataText="没有任何选项" AutoGenerateColumns="False" onrowdeleting="gv_RowDeleting"> <RowStyle HorizontalAlign="Center" VerticalAlign="Middle" /> <Columns> <asp:BoundField DataField="line_id" Visible="False" /> <asp:BoundField DataField="line_text" HeaderText="选项"/> <asp:BoundField DataField="line_odds" HeaderText="赔率"/> <asp:BoundField DataField="line_status" HeaderText="状态" /> </Columns> <HeaderStyle BorderStyle="Solid" BorderWidth="1px" HorizontalAlign="Center" VerticalAlign="Middle" /> <AlternatingRowStyle BackColor="#9999FF" HorizontalAlign="Center" VerticalAlign="Middle" Width="695px" Wrap="False" /> </asp:GridView>
protected void gv_RowDeleting(object sender, GridViewDeleteEventArgs e) { GridViewRow row = gv.Rows[e.RowIndex]; int result = DB.DeleteLine(Int32.Parse(row.Cells[0].ToString())); gv.DeleteRow(e.RowIndex); }