Welcome to Dream.In.Code
Become an Expert!

Join 149,602 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,899 people online right now. Registration is fast and FREE... Join Now!




Help with LinkButton in Gridview

 
Reply to this topicStart new topic

Help with LinkButton in Gridview

Sim270
17 Oct, 2007 - 05:36 AM
Post #1

New D.I.C Head
*

Joined: 4 Jul, 2007
Posts: 16


My Contributions
I have one gridview with the <a href> tag in the template column.
In href i have given the path to documents which reside in the folder present in the application directory.these path will be dynamically generated and binded in design with eval("column_name") to the href property.

But now i want to perform some server side processing also taking the name and path of the link
along with opening of the doc in the new window ,on click of the link
So i changed the html links to link button but m not able to get the proper approach to go for it.....


Can anybody tell the best approach which can be followed for .
can i use something other than link button.





User is offlineProfile CardPM
+Quote Post

avolel
RE: Help With LinkButton In Gridview
30 Nov, 2007 - 12:02 PM
Post #2

New D.I.C Head
*

Joined: 24 Aug, 2005
Posts: 38



Thanked: 1 times
My Contributions
QUOTE(Sim270 @ 17 Oct, 2007 - 06:36 AM) *

I have one gridview with the <a href> tag in the template column.
In href i have given the path to documents which reside in the folder present in the application directory.these path will be dynamically generated and binded in design with eval("column_name") to the href property.

But now i want to perform some server side processing also taking the name and path of the link
along with opening of the doc in the new window ,on click of the link
So i changed the html links to link button but m not able to get the proper approach to go for it.....


Can anybody tell the best approach which can be followed for .
can i use something other than link button.


In your GridView1_RowDataBound Method you should add the onclick attribute to the hyperlink and set its value to a Javascript method that would do whatever you want it to do when the user clicks the link. your method should look like:

//In Code Behind
protected void gGridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
HyperLink hyplnk = (HyperLink)e.Row.FindControl("hyperlinkName");
hyplnk.Attributes.Add("onclick", "ShowModalPopup()");
}
}

//In markup
<a href='<%# Eval("link")%>'><%# Eval("title") %></a>


User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/7/09 11:49PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month