<asp:TemplateField HeaderText="锁定">
<ItemStyle CssClass="GridViewItemGlLeft" />
<HeaderStyle CssClass="GridViewHeader" Width="3%" />
<ItemTemplate>
<asp:ImageButton ID="image1" runat="server" ImageUrl="~/images/unlock.gif" ToolTip="未锁定,锁定后不可编辑、删除!"
CommandArgument='<%# Eval("wpbh") %>' PostBackUrl="LockMessage.aspx?wpbh={0}"
Style="display: none" CommandName="LockMail" />
<asp:ImageButton ID="image2" runat="server" ImageUrl="~/images/lock.gif" ToolTip="已锁定,系统管理员可解锁"
OnClientClick="return confirm('确定要解锁该数据吗?')" Style="display: none" CommandArgument='<%# Bind("wpbh") %>'
CommandName="ReleaseMail" />
</ItemTemplate>
</asp:TemplateField>
以上是我gridview里的一列,目的是想点击未锁定图片跳转到页面进行锁定操作,可现在问题是能跳转过去但是页面传值传不过去,锁定页面wpbh一致是{0}求高手指教?
<ItemStyle CssClass="GridViewItemGlLeft" />
<HeaderStyle CssClass="GridViewHeader" Width="3%" />
<ItemTemplate>
<asp:ImageButton ID="image1" runat="server" ImageUrl="~/images/unlock.gif" ToolTip="未锁定,锁定后不可编辑、删除!"
CommandArgument='<%# Eval("wpbh") %>' PostBackUrl="LockMessage.aspx?wpbh={0}"
Style="display: none" CommandName="LockMail" />
<asp:ImageButton ID="image2" runat="server" ImageUrl="~/images/lock.gif" ToolTip="已锁定,系统管理员可解锁"
OnClientClick="return confirm('确定要解锁该数据吗?')" Style="display: none" CommandArgument='<%# Bind("wpbh") %>'
CommandName="ReleaseMail" />
</ItemTemplate>
</asp:TemplateField>
以上是我gridview里的一列,目的是想点击未锁定图片跳转到页面进行锁定操作,可现在问题是能跳转过去但是页面传值传不过去,锁定页面wpbh一致是{0}求高手指教?
一、另外加一模版列
<asp:TemplateField HeaderText="wpbh" Visible="false">
<ItemTemplate>
<asp:Label ID="lblID" runat="server" Text='<%# Eval("wpbh") %>' Visible="False" ></asp:Label>
</ItemTemplate>
</asp:TemplateField>
RowCommand事件
Label lblwpbh = (Label)this.gvList.Rows[Convert.ToInt32(e.CommandArgument)].FindControl("lblID");
string strWpbh=lblwpbh.text;二、在gridview加上DataKeyNames="wpbh"
RowCommand事件
GridViewRow drv = ((GridViewRow)(((ImageButton)(e.CommandSource)).Parent.Parent));
string strWpbh=gridview.DataKeys[drv.RowIndex][0].ToString();//选中列
我是刚入门的程序员,看台还可以,后台代码有点不懂!
下面在贴上详细代码吧!
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CssClass="GridView"
EmptyDataText="没有满足条件的记录!" Width="751px" OnRowDeleting="GridView1_RowDeleting"
CellPadding="4" ForeColor="#333333" GridLines="None" AllowPaging="True" OnRowDataBound="GridView1_RowDataBound"
DataKeyNames="wpbh,sd" OnRowCommand="GridView1_RowCommand">
<PagerSettings Visible="False" />
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="#EFF3FB" />
<EmptyDataRowStyle CssClass="GridViewEmptyData" />
<Columns>
<asp:HyperLinkField DataNavigateUrlFields="wpbh" DataNavigateUrlFormatString="AirCargo_infocollect_Details.aspx?wpbh={0}"
DataTextField="wpbh" HeaderText="物品编号" Target="_self">
<ItemStyle CssClass="GridViewItemGl" />
<HeaderStyle CssClass="GridViewHeader" Width="8%" />
</asp:HyperLinkField>
.....其他列...
<asp:TemplateField HeaderText="锁定">
<ItemStyle CssClass="GridViewItemGlLeft" />
<HeaderStyle CssClass="GridViewHeader" Width="3%" />
<ItemTemplate>
<asp:ImageButton ID="image1" runat="server" ImageUrl="~/images/unlock.gif" ToolTip="未锁定,锁定后不可编辑、删除!"
CommandArgument='<%# Eval("wpbh") %>' PostBackUrl="LockMessage.aspx?wpbh={0}"
Style="display: none" CommandName="LockMail" />
<asp:ImageButton ID="image2" runat="server" ImageUrl="~/images/lock.gif" ToolTip="已锁定,系统管理员可解锁"
OnClientClick="return confirm('确定要解锁该数据吗?')" Style="display: none" CommandArgument='<%# Bind("wpbh") %>'
CommandName="ReleaseMail" />
</ItemTemplate>
</asp:TemplateField>