link button in a datagrid column
-
I am working on a web application, in which i have a datagrid with a template column consisting of linkbuttons. Now if i click each linkbutton one corresponding file ( pdf/doc) should open. How can i write code for this scenario.
Create an event handler for the grid's
ItemCommand
event (the event will fire when a user presses the linkbutton in the template column). When the event is fired, the event args will include the current row, so you should be able to get whatever information you need about what file you'd like to open. Remember to check which command fired the event if you have more than one button column in the grid. Hope this helps.The most exciting phrase to hear in science, the one that heralds the most discoveries, is not 'Eureka!' ('I found it!') but 'That's funny...’
-
I am working on a web application, in which i have a datagrid with a template column consisting of linkbuttons. Now if i click each linkbutton one corresponding file ( pdf/doc) should open. How can i write code for this scenario.
Hi 1. use Template colume in the data grid 2. save the file name in the database use this code
code behind Dim keys As String = dg_topic_list.DataKeys(dg_topic_list.SelectedIndex) Dim RedirectPage As String = "../mentoring/mentortopics.aspx" If File.Exists("system path\files\" & data.ReturnDs(sql_str).Tables(0).Rows(0).Item("filename") & ".pdt") Then Response.Redirect("./files/" & data.ReturnDs(sql_str).Tables(0).Rows(0).Item("filename") & ".pdf") End If
bye timcyspet