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

时间:2022-08-31 21:00:03

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" style="margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; background: rgb(242, 246, 251); width: 640px; clear: both; border-top: 1px solid rgb(0, 153, 204); border-right: 1px solid rgb(0, 153, 204); border-left: 1px solid rgb(0, 153, 204); border-image: initial; border-bottom: none; font-family: tahoma, arial, "Microsoft YaHei";"> 复制代码代码如下:


<asp:TemplateField HeaderText="View"> 
<ItemTemplate> 
<a href="DraftVesselOrderDetail.aspx?ServiceID=<%#Eval("Number") %>&TripSelectedIndex= <%# Container.DataItemIndex %>"> 
<img style="border: 0" /> 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;