<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}求高手指教?

解决方案 »

  1.   

    锁定页面用request.querystring取值一致是{0}
      

  2.   


    一、另外加一模版列
    <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();//选中列
      

  3.   

    你这个我看着是当前页面的取值吧,我想要的是跳转到LockMessage.aspx这个页面,在这个页面能取值到wpbh,另外我gridview第一列有模板列wpbh了,那一列是点击跳转详细页,目前就是锁定功能跳转过去值取不到!
    我是刚入门的程序员,看台还可以,后台代码有点不懂!
    下面在贴上详细代码吧!
     <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>
      

  4.   

    PostBackUrl='<%# "LockMessage.aspx?wpbh="+Eval("wpbh") %>'
      

  5.   

    你是怎么跳转的   把值接跟在跳转后面跳转过去  Request.QueryString接收
      

  6.   

    6楼的方法试了可以,值取到了!跳转这个语句啊:PostBackUrl="LockMessage.aspx?wpbh={0}"照6楼看这句话有问题!