62,046
社区成员
发帖
与我相关
我的任务
分享
protected void gv_Vaccinate_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "DataDelete")
{
int ID = 0;
if (int.TryParse(e.CommandArgument.ToString(), out ID))
{
bool result = (new Vaccinate()).Update(ID, 1);
if (result)
{
ClientScript.RegisterStartupScript(this.GetType(), "DelSuccess", "<script>alert('删除成功!')</script>");
gv_Vaccinate.DataBind();
}
else
{
ClientScript.RegisterStartupScript(this.GetType(), "DelError", "<script>alert('删除失败!')</script>");
}
}
}
}
protected void gv_Vaccinate_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "DataDelete")
{
int ID = 0;
if (int.TryParse(e.CommandArgument.ToString(), out ID))
{
bool result = (new Vaccinate()).Update(ID, 1);
if (result)
{
ClientScript.RegisterStartupScript(this.GetType(), "DelSuccess", "<script>alert('删除成功!')</script>");
gv_Vaccinate.DataBind();
Response.Redirect(Request.UrlReferrer.ToString());
}
else
{
ClientScript.RegisterStartupScript(this.GetType(), "DelError", "<script>alert('删除失败!')</script>");
}
}
}
}
//aspx里的代码
<asp:GridView ID="gv_Vaccinate" runat="server" AllowPaging="True" AutoGenerateColumns="False"
BackColor="White" BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px"
CellPadding="3" DataSourceID="ods_Vaccinate" PageSize="16" OnRowCommand="gv_Vaccinate_RowCommand"
Width="100%" OnRowDataBound="gv_Vaccinate_RowDataBound">
<Columns>
<asp:TemplateField HeaderText="序号">
<ItemTemplate>
<%# m_Index++%>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="DEVICEID" HeaderText="设备号" SortExpression="DEVICEID" />
<asp:BoundField DataField="RAISERS" HeaderText="畜主" SortExpression="RAISERS" />
<asp:BoundField DataField="IN_DATE" HeaderText="防疫时间" SortExpression="IN_DATE" />
<asp:BoundField DataField="VACCINATE_NAME" HeaderText="注射疫苗名称" SortExpression="VACCINATE_NAME" />
<asp:BoundField DataField="REGION_NAME" HeaderText="乡镇名称" SortExpression="REGION_NAME" />
<asp:BoundField DataField="EARMARK_SERIAL" HeaderText="耳标号" SortExpression="EARMARK_SERIAL" />
<asp:BoundField DataField="LASTDATE" HeaderText="完成时间" SortExpression="LASTDATE" />
<asp:BoundField DataField="ISINIT" HeaderText="初始化" SortExpression="ISINIT" />
<asp:TemplateField HeaderText="删除" HeaderStyle-HorizontalAlign="Center">
<ItemTemplate>
<asp:ImageButton ID="ib_Delete" runat="server" CausesValidation="False" CommandName="DataDelete"
CommandArgument='<%# Eval("ID") %>' OnClientClick="return confirm('是否删除该条记录?')"
ToolTip="删除" ImageUrl="/images/delete.png" />
</ItemTemplate>
<HeaderStyle HorizontalAlign="Center"></HeaderStyle>
<ItemStyle HorizontalAlign="Center" />
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="White" ForeColor="#000066" />
<HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Right" />
<RowStyle ForeColor="#000066" />
<SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#F1F1F1" />
<SortedAscendingHeaderStyle BackColor="#007DBB" />
<SortedDescendingCellStyle BackColor="#CAC9C9" />
<SortedDescendingHeaderStyle BackColor="#00547E" />
</asp:GridView>
//aspx.cs里的代码
protected void gv_Vaccinate_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "DataDelete")
{
int ID = 0;
if (int.TryParse(e.CommandArgument.ToString(), out ID))
{
bool result = (new Vaccinate()).Update(ID, 1);
if (result)
{
ClientScript.RegisterStartupScript(this.GetType(), "DelSuccess", "<script>alert('删除成功!')</script>");
//gv_Vaccinate.DataBind();
}
else
{
ClientScript.RegisterStartupScript(this.GetType(), "DelError", "<script>alert('删除失败!')</script>");
}
}
}
}