Click here to Skip to main content
15,907,493 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to pass a query string using a href inside gridview item template
----------------------------------

This is my code.



Here, I don't want to open new window, Just I want to redirect to AddRecords.aspx page and pass query string.

Please help.

Thanks
Posted
Comments
Hemant Singh Rautela 17-Dec-13 3:09am    
I think you can use JSON or javascript for it for call a another page without opening it.

 
Share this answer
 
Hi Try like this,


XML
<asp:TemplateField>
                <ItemTemplate>
                    <asp:HyperLink runat="server" ID="HyperLink1" NavigateUrl='<%# "yoururl.aspx?string1=" + Eval("value1")%>'
                        Text='click'></asp:HyperLink>
                </ItemTemplate>
            </asp:TemplateField>
 
Share this answer
 
I would Prefer Add LinkButton in Gridview
ASP.NET
<asp:templatefield headertext="Add Record" xmlns:asp="#unknown">
    <itemtemplate>
       <asp:linkbutton id="lbAdd" cssclass="link" runat="server" commandname="Add Record">
 CommandArgument='<%# Eval("SomeID")%>'>Edit</asp:linkbutton>
    </itemtemplate>
 </asp:templatefield>

C#
//On RowCommand Try this
protected void gvStudent_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        switch (e.CommandName)
        {
            case "Add Record":
                Server.Transfer(string.Format("YourPageName.aspx?ID={0}&mode=Add", Convert.ToString(e.CommandArgument)));
         break;
        }
}
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900