我想通过模版列中的HyperLink的NavigateUrl传递3个参数,其中两个参数就是Gridview的绑定字段,另外一个参数是我后台代码中处理过的参数.
<asp:GridView ID="GridView1" runat="server" DataKeyNames ="planbillno,goodsclass" DataSourceID="SqlDataSource1" AutoGenerateColumns="False" OnRowDataBound="custom_databound" GridLines="Vertical"  Width ="1000px"  PageSize="17" OnRowCreated="GridView1_RowCreated" >         
         <Columns>
             <asp:TemplateField HeaderText="储备计划编号">
                 <ItemTemplate>
                     <asp:HyperLink ID="HyperLink2" runat="server" 
                         Text='<%# Eval("planbillno") %>'></asp:HyperLink>
                 </ItemTemplate>
             </asp:TemplateField>
                <asp:BoundField DataField="type" HeaderText="计划性质"/>
                <asp:BoundField DataField="goodsclass" HeaderText="品种"/>
                <asp:BoundField DataField="planweight_bill" HeaderText="轮出计划数">
                    <ItemStyle HorizontalAlign="Right" />
                </asp:BoundField>
                <asp:BoundField DataField="contractweight" HeaderText="销售合同数">
                    <ItemStyle HorizontalAlign="Right" />
                </asp:BoundField>
                <asp:BoundField DataField="contractrate" HeaderText="落实%">
                    <ItemStyle HorizontalAlign="Right" />
                </asp:BoundField>
                 <asp:BoundField DataField="psweight" HeaderText="客户提单数">
                    <ItemStyle HorizontalAlign="Right" />
                </asp:BoundField>
                <asp:BoundField DataField="psrate" HeaderText="提货%">
                    <ItemStyle HorizontalAlign="Right" />
                </asp:BoundField>
                <asp:BoundField DataField="realweight" HeaderText="实际完成数">
                    <ItemStyle HorizontalAlign="Right" />
                </asp:BoundField>
                <asp:BoundField DataField="rate" HeaderText="完成%">
                    <ItemStyle HorizontalAlign="Right" />
                </asp:BoundField>
                <asp:BoundField DataField="noquantity" HeaderText="未完成数量">
                    <ItemStyle HorizontalAlign="Right" />
                </asp:BoundField>
                <asp:BoundField DataField="norate" HeaderText="未完成%" >
                    <ItemStyle HorizontalAlign="Right" />
                </asp:BoundField>
         </Columns> 
        </asp:GridView>
---------------------------------------------
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
    {
        string lsdate = ver.DateTimeType(tb_lsdate.Text);
        HyperLink l = GridView1.FindControl("HyperLink2") as HyperLink;
        l.NavigateUrl = string.Format("~/webpage/grease_report_ps_cb_outplan_detail.aspx?planbillno={0}&lsdate={1}&goodsname={2}",  e.Row.Cells [0].Text , lsdate,e.Row .Cells [2].Text );
    //该句这样写报错,说没有实例化对象
}

解决方案 »

  1.   

    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
       if (e.Row.RowType == DataControlRowType.DataRow)
       {
           string lsdate = ver.DateTimeType(tb_lsdate.Text);
           HyperLink l = e.Row.FindControl("HyperLink2") as HyperLink;
           l.NavigateUrl = string.Format("~/webpage/grease_report_ps_cb_outplan_detail.aspx?planbillno={0}&lsdate={1}&goodsname={2}",  e.Row.Cells [0].Text , lsdate,e.Row .Cells [2].Text );   }
    }
      

  2.   

    <asp:GridView ID="GridView1" runat="server" DataKeyNames ="planbillno,goodsclass" DataSourceID="SqlDataSource1" AutoGenerateColumns="False" OnRowDataBound="custom_databound" GridLines="Vertical"  Width ="1000px"  PageSize="17" OnRowDataBound="GridView1_RowDataBound">
      

  3.   

    还是不行
    我把l.NavigateUrl = "~/webpage/grease_report_ps_cb_outplan_detail.aspx";都会报"未将对象引用设置到对象的实例"的错
      

  4.   

    通过QueryString传递,都绑定到NavigateUrl上面去,例如:
    NavigateUrl='<%# string.Format("TargetPage.aspx?Argument1={0}&Argument2={1}", Eval("Argument1").ToString(), Eval("Argument2").ToString()) %>'
      

  5.   

    to cat_hsfz
    那我怎么获取后台代码中处理过的值(那个lsdate)呢?
    如果实在不行,我怎么在前台页面获取一个textbox的值呢?