Click here to Skip to main content
15,902,299 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Dear All,

gridview contain columns: id, image, title,location
rows: 5

once click first row title(computer)
this link go to computer.aspx

2nd row title(Accountant)
this link go to accountant.aspx

3rd row title(laptop)
this link go to laptop.aspx

4th row title(camera)
this link go to camera.aspx

5th row title(mobile)
this link go to mobile.aspx

this link navigation is possible or not

please reply me

possible : how

please reply me any logic or examples sites or url paths

or here navigation purpose gridview or another control what control are use
please reply me
Posted
Updated 20-Feb-14 19:22pm
v2

Use RowCommand Event for this:

Try this:
C#
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
  {
    GridViewRow row = (GridViewRow)((LinkButton)e.CommandSource).NamingContainer;
          int rowIndex = row.RowIndex;

          if (rowIndex == 0)
          {
          Response.Redirect("computer.aspx");
          }
          else if (rowIndex == 1)
          {
          Response.Redirect("accountant.aspx");
          }
         /// and so on
 }


and read this:
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.rowcommand%28v=vs.110%29.aspx[^]
 
Share this answer
 
Comments
member1431 21-Feb-14 1:42am    
Here navigation is ok

but

here please try to understand give me reply please

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="gridnavigate.aspx.cs" Inherits="gridnavigate" %>

<!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 runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>

<asp:GridView ID="GridView1" runat="server" AllowPaging="True" Width="100%"
HeaderStyle-HorizontalAlign="Justify" GridLines="Horizontal"
AutoGenerateColumns="False" DataKeyNames="Id"
DataSourceID="SqlDataSource1" onrowcommand="GridView1_RowCommand">
<columns>
<asp:CommandField ShowSelectButton="True" Visible="False" />
<asp:BoundField DataField="Id" HeaderText="Id" InsertVisible="False"
ReadOnly="True" SortExpression="Id" />
<asp:TemplateField HeaderText="Image" SortExpression="Image">
<edititemtemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Image") %>'>

<itemtemplate>
<asp:Image ID="Image1" Width="100px" Height="100px" runat="server" ImageUrl='<%# Bind("Image") %>'>


<asp:TemplateField HeaderText="Title" SortExpression="Title">
<edititemtemplate>
<asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("Title") %>'>

<itemtemplate>
<asp:LinkButton ID="LinkButton2" runat="server" Text='<%# Bind("Title") %>'>


<asp:BoundField DataField="Description" HeaderText="Description"
SortExpression="Description" />
<asp:BoundField DataField="Price" HeaderText="Price" SortExpression="Price" />
<asp:BoundField DataField="Location" HeaderText="Location"
SortExpression="Location" />

<HeaderStyle HorizontalAlign="Justify" />

<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:AbcClassifiedsConnectionString %>"

SelectCommand="SELECT [Id], [Image], [Title], [Description], [Price], [Location] FROM [ProductDetails] where CategoriesType='Computer'">

</div>
</form>
</body>
</html>

here computer related will come through database
In Title column Once click go to that perticular .aspx page like computer(row1) and new computer model(row2)

this is possible or not and this way correct or not please reply correct way and answer
Tom Marvolo Riddle 21-Feb-14 1:46am    
please wait...
member1431 21-Feb-14 2:20am    
yes am waiting your reply
Tom Marvolo Riddle 21-Feb-14 2:38am    
sorry for the late reply.In Title column Once click go to that perticular .aspx page like computer(row1) and new computer model(row2) " will you explain?
Tom Marvolo Riddle 21-Feb-14 3:42am    
glad you solved the problem
use hyperlink field in Gridview

C#
<asp:gridview id="OrdersGridView"
       datasourceid="OrdersSqlDataSource"
       autogeneratecolumns="false"
       runat="server">

       <columns>

         <asp:boundfield datafield="ID"
           headertext="Order ID"/>
         <asp:boundfield datafield="title"
           headertext="title "/>
  <asp:boundfield datafield="location"
           headertext="Location"/>
         <asp:hyperlinkfield datatextfield="Computer"
           datatextformatstring="{0:c}"
           datanavigateurlfields="ProductID"
           datanavigateurlformatstring="~\Computer.aspx?"
           headertext="Price"
           target="_blank" />
       

       </columns>

     </asp:gridview>
 
Share this answer
 

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