datagrid行内按钮(更新/删除等)操作实现代码

网络编程 2021-07-04 22:40www.168986.cn编程入门
datagrid控件想必大家很是熟悉,本文将介绍下datagrid行内按钮的操作更新/删除等等,感兴趣的你可不要错过了哈,希望本文知识点可以帮助到你
ui:
代码如下:

<asp:TemplateField HeaderText="Operation" ShowHeader="False">
<ItemStyle Width="100px" />
<ItemTemplate>
<table width="100%">
<tr>
<td align="center" valign="middle">
<asp:ImageButton ID="imgUpdate" CommandName="update" ToolTip="Update" ImageUrl="~/App_Themes/Images/edit.png"
runat="server" />
<%--<a href="ApplicationDetail.aspx?type=update&ApplicationID=<%#Eval("ApplicationID") %>">
<img style="border: 0" width="12" height="12" alt="Update" src="../Themes/images/edit.png" /></a>--%>
</td>
<td align="center" valign="middle">
&nbsp;&nbsp;
<asp:ImageButton ID="imgDelete" CommandName="delete" ToolTip="Delete" ImageUrl="~/App_Themes/Images/del.png"
runat="server" />
</td>
</tr>
</table>
</ItemTemplate>
</asp:TemplateField>

代码如下:

<asp:TemplateField HeaderText="View">
<ItemTemplate>
<a href="DraftVesselOrderDetail.aspx?ServiceID=<%#Eval("Number") %>&TripSelectedIndex= <%# Container.DataItemIndex %>">
<img style="border: 0" alt="View" src="../../App_Themes/Images/preview.gif" /></a>
</ItemTemplate>
</asp:TemplateField>

Code
代码如下:

protected void gdvOrderList_RowCommand(object sender, GridViewCommandEventArgs e)
{
switch (e.CommandName.ToLower())
{
case "view":
var serviceId = long.Parse(e.CommandArgument.ToString());
Response.Redirect("DraftOrderDetail.aspx?type=view&ServiceID=" + serviceId + "&FromPage=Order&GridPageIndex=" + serviceId);
break;
}
}

Copyright © 2016-2025 www.168986.cn 狼蚁网络 版权所有 Power by