Reputation: 2208
I currently have 5 rows in my table say (no,name,address,phone,age) I'm displaying the values from the sql and displaying no and name in firstpage.aspx via GridView
1.Now what I want is, when I click on any name in the gridview should display the adjacent values (address ,phone ,age)in newpage.aspx page
2.The problem im facing is, I'm not able to make the fields in the gridview clickable.
3.Is it possible to make the elements in the gridivew clickable or can u guys suggest me another way of making this possible or is there anyother way of retrieving datas from the db other than the gridview?
Upvotes: 0
Views: 1121
Reputation: 2411
You can make columns clickable. It would be easy if you use TemplateFields and ItemTemplates. For example:
<Columns>
<asp:TemplateField>
<ItemTemplate>
<a href="#" onclick="redirect('<%# Eval("some_ID") %>')"><%# Eval ("some_Fieldname") %></a>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
...
</asp:TemplateField>
</Columns>
You can use a javascript for redirect such as
function redirect(target)
{
window.open('some_url/some_page?id='+target+'','mytarget');
}
In the template field you can use any html tag like DIV or SPAN instead of HREF.
In the target page, you can capture this Id and make necessary coding.
Upvotes: 1