比如我页面有个text1文本框
内容由用户写
然后我在gridview中需要做个链接
AAA.ASPX?aaa=text1.text现在我写protected string aa = text1.text
然后
gridview中
        DataNavigateUrlFormatString='person.aspx?aaa=<%=aa%>'
但链接出还是 
person.aspx?aaa=<%=aa%>
不是我需要的值
请问下怎么修改

解决方案 »

  1.   


    DataNavigateUrlFormatString='person.aspx?aaa= "+this.text1.text+"' 
      

  2.   

    如果aa是处理过的值那就,放注入吗!?
    DataNavigateUrlFormatString='person.aspx?aaa= "+aa+"' 
      

  3.   

    使用模板列,在RowDataBound事件中动态指定,示例代码:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>测试页面</title>
    </head>
    <body>
        <form id="form1" runat="server">
            <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" OnRowDataBound="GridView1_RowDataBound">
                <Columns>
                    <asp:TemplateField>
                        <ItemTemplate>
                            <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField>
                        <ItemTemplate>
                            <asp:HyperLink ID="HyperLink1" runat="server">HyperLink</asp:HyperLink>
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
            </asp:GridView>
        </form>
    </body>
    </html>
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            TextBox txt = e.Row.FindControl("TextBox1") as TextBox;
            HyperLink link = e.Row.FindControl("HyperLink1") as HyperLink;
            link.NavigateUrl = "你的链接&你的参数名称=" + txt.Text;
        }
    }
      

  4.   

    ls的老大 谢谢
    能用了
    还有个问题
    我表中有个id字段
    想问下怎么取选中的这个ID字段~~