Click here to Skip to main content
15,662,532 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I want have a gridview populating details from a database. In the grid i want certain colums to be work as hyperlinks. Also hyperlinks directs to another page which expects values in the hyperlink query string. The details which i need to pass is in the other colums of the grid. I tried and partially successfull. I collects the column value in code behind page and append with the navigate url string. After data bind i make the value column invisible so that there wont be a link and a datafield with same value.

My question is is there any simple way to do it???
May be using Java script??? if yes can any one give me some over view??Some sample code will be Great??
Thanks
Posted

Don't do it in JavaScript, use the grid view templates to achieve what you want. Sample
 
Share this answer
 
Comments
KingsKnight 4-Jun-10 22:58pm    
Actually I don't want to do any SQl operation with that link. I juct want to redirect that hyperlink to other psges with values in query string. the values in query string is getting from other columns of the Gridview.
That is the problem ....
Actually I don't want to do any SQl operation with that link. I juct want to redirect that hyperlink to other psges with values in query string. the values in query string is getting from other columns of the Gridview.
That is the problem ....


No one to answer???:(
 
Share this answer
 
So can't you just use a hyperlink field....as follows

XML
<asp:GridView ID="SummaryView" runat="server" AutoGenerateColumns="False">
    <Columns>
        <asp:HyperLinkField DataNavigateUrlFields="MyIdentifier" DataNavigateUrlFormatString="~/Pages/ChangeRequestDetails.aspx?requestId={0}"
            DataTextField="MyIdentifier" HeaderText="Request ID">
            <ItemStyle CssClass="reference" />
        </asp:HyperLinkField>
    </Columns>
</asp:GridView>


So in the above GridView example, there is one HyperLinkField that is bound to a data field called 'MyIdentifier' (or whatever you like!). The value of the field then forms part of DataNavigateUrlFormatString

You can have your hyperlink field use numerous data values and form the link URL. e.g

<asp:HyperLinkField DataNavigateUrlFields="CustomerID, CompanyName, ContactName, Address, City" DataNavigateUrlFormatString="CustomerDetails.aspx?CID={0}&CName={1}&ContactName={2}&Addr={3}&City={4}" Text="Pass Multiple Values" /> 
 
Share this answer
 
v3
No i cant. That Java script determines to which page it should redirect.....
 
Share this answer
 
Comments
Dylan Morley 9-Jun-10 5:53am    
OK, post what code you've got so far and we can maybe see what you're doing. If all you want is a column in your GridView to act as a redirect, then what I have posted is the way to do it, absolutely no need for Javascript. If you're doing something else, then we need to see the code to determine.

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