Friday, February 12, 2010

Asp.net gridview control question, need hyperlink?

hi,


grid view control is populated with the values from the database.


how can i make a cell value as a hyper link and how can i get the value of a cell which i have selected in the grid view control.





sample o/p :





File1.txt


File2.doc





file1.txt and file2.doc is the data that comes from database and when they come into the webpage they should be displayed as links.when these links are clicked respective files should be opened which are in the webserver





thankx in advance.Asp.net gridview control question, need hyperlink?
n your declarative code (aspx file) add the following:


%26lt;asp:GridView ID=';gvwTest'; runat=';server'; AutoGenerateColumns=';true';


%26lt;Columns%26gt;


%26lt;asp:TemplateField HeaderText = ';Download File';%26gt;


%26lt;ItemTemplate%26gt;


%26lt;a id=';lnkDownloadFile'; runat =';server'; href = './YourUploadFolder/ %26lt;%# Eval(';FileName';) %%26gt; ' /%26gt;


%26lt;/ItemTemplate%26gt;


%26lt;/asp:TemplateField%26gt;


%26lt;/Columns%26gt;


%26lt;/asp:GridView%26gt;





Hope this helps.
  • Scooter
  • No comments:

    Post a Comment