Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Hyper Link in datagrid to download a file

Hyper Link in datagrid to download a file

Scheduled Pinned Locked Moved ASP.NET
csharpdatabaseasp-nettutorial
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Tash18
    wrote on last edited by
    #1

    Hi guys, Im working on asp.net1.1 web application on C#. actually i have a page in which the user fills up certain details and also have an option to upload a file which is mandatory. Now at the database along with the details entered by the user the file location path also gets saved in the database say for example D:\webapp\Hello\Modules\Agreement\01-11-2010 08-43-50AMimage.gif -- dis is what gets stored in the DB. Now after the user has clicked the submit button the data is inserted and i also have a datagrid in the same page on which the data stored in database gets populated, currently the path of the file is displayed on the datagrid as mentioned above. but what my requirement is i want the path to be displayed as a hyperlink so dat on clicking the link the file gets downloaded.. trhe code is as follows the following code is on page display.aspx.cs

    	private void BindAgreement()
    	{
    		string Module = Request.QueryString\["servId"\];
    		DataSet dReasons  = DataAccess.ExecuteStoredProcedure(Session\["MosaicConn"\].ToString(),"asp\_app\_get\_mainagreement "+Module);
    		if(dReasons.Tables.Count > 0)
    		{
    			if(dReasons.Tables\[0\].Rows.Count > 0)
    			{
    				DataTable dtDisplay = new DataTable();
    				dtDisplay.Columns.Add(new DataColumn("row\_id",typeof(string)));
    				dtDisplay.Columns.Add(new DataColumn("module\_id",typeof(string)));
    				dtDisplay.Columns.Add(new DataColumn("total\_value",typeof(string)));
    				dtDisplay.Columns.Add(new DataColumn("amc\_start\_dt",typeof(string)));
    				dtDisplay.Columns.Add(new DataColumn("license\_amt",typeof(string)));
    				dtDisplay.Columns.Add(new DataColumn("implement\_amt",typeof(string)));
    				dtDisplay.Columns.Add(new DataColumn("number\_of\_licenses",typeof(string)));
    				dtDisplay.Columns.Add(new DataColumn("agree\_file\_name",typeof(string)));
    
    				for(int i = 0; i < dReasons.Tables\[0\].Rows.Count; i++)
    				{
    					DataRow drDisplay;
    					drDisplay = dtDisplay.NewRow();
    					drDisplay\[0\] = dReasons.Tables\[0\].Rows\[i\].ItemArray\[0\];
    					drDisplay\[1\] = dReasons.Tables\[0\].Rows\[i\].ItemArray\[1\];
    					drDisplay\[2\] = dReasons.Tables\[0\].Rows\[i\].ItemArray\[2\];
    					drDisplay\[3\] = dReasons.Tables\[0\].Rows\[i\].ItemArray\[3\];
    					drDisplay\[4\] = dReasons.Tables\[0\].Rows\[i\].ItemArray\[4\];
    					drDisplay\[5\] = dReasons.Tables\[0\].Rows\[i\].ItemArray\[5\];
    					drDisplay\[6\] = dReasons.Tables\[0\].Rows\[i\].ItemArray\[6\];
    					drDisplay\[7\] = dReasons.Tables\[0\].Rows\[i\].ItemArray\[7\];
    					dtDisplay.Rows.Add(drDisplay);
    				}
    				lblMes
    
    N 1 Reply Last reply
    0
    • T Tash18

      Hi guys, Im working on asp.net1.1 web application on C#. actually i have a page in which the user fills up certain details and also have an option to upload a file which is mandatory. Now at the database along with the details entered by the user the file location path also gets saved in the database say for example D:\webapp\Hello\Modules\Agreement\01-11-2010 08-43-50AMimage.gif -- dis is what gets stored in the DB. Now after the user has clicked the submit button the data is inserted and i also have a datagrid in the same page on which the data stored in database gets populated, currently the path of the file is displayed on the datagrid as mentioned above. but what my requirement is i want the path to be displayed as a hyperlink so dat on clicking the link the file gets downloaded.. trhe code is as follows the following code is on page display.aspx.cs

      	private void BindAgreement()
      	{
      		string Module = Request.QueryString\["servId"\];
      		DataSet dReasons  = DataAccess.ExecuteStoredProcedure(Session\["MosaicConn"\].ToString(),"asp\_app\_get\_mainagreement "+Module);
      		if(dReasons.Tables.Count > 0)
      		{
      			if(dReasons.Tables\[0\].Rows.Count > 0)
      			{
      				DataTable dtDisplay = new DataTable();
      				dtDisplay.Columns.Add(new DataColumn("row\_id",typeof(string)));
      				dtDisplay.Columns.Add(new DataColumn("module\_id",typeof(string)));
      				dtDisplay.Columns.Add(new DataColumn("total\_value",typeof(string)));
      				dtDisplay.Columns.Add(new DataColumn("amc\_start\_dt",typeof(string)));
      				dtDisplay.Columns.Add(new DataColumn("license\_amt",typeof(string)));
      				dtDisplay.Columns.Add(new DataColumn("implement\_amt",typeof(string)));
      				dtDisplay.Columns.Add(new DataColumn("number\_of\_licenses",typeof(string)));
      				dtDisplay.Columns.Add(new DataColumn("agree\_file\_name",typeof(string)));
      
      				for(int i = 0; i < dReasons.Tables\[0\].Rows.Count; i++)
      				{
      					DataRow drDisplay;
      					drDisplay = dtDisplay.NewRow();
      					drDisplay\[0\] = dReasons.Tables\[0\].Rows\[i\].ItemArray\[0\];
      					drDisplay\[1\] = dReasons.Tables\[0\].Rows\[i\].ItemArray\[1\];
      					drDisplay\[2\] = dReasons.Tables\[0\].Rows\[i\].ItemArray\[2\];
      					drDisplay\[3\] = dReasons.Tables\[0\].Rows\[i\].ItemArray\[3\];
      					drDisplay\[4\] = dReasons.Tables\[0\].Rows\[i\].ItemArray\[4\];
      					drDisplay\[5\] = dReasons.Tables\[0\].Rows\[i\].ItemArray\[5\];
      					drDisplay\[6\] = dReasons.Tables\[0\].Rows\[i\].ItemArray\[6\];
      					drDisplay\[7\] = dReasons.Tables\[0\].Rows\[i\].ItemArray\[7\];
      					dtDisplay.Rows.Add(drDisplay);
      				}
      				lblMes
      
      N Offline
      N Offline
      Not Active
      wrote on last edited by
      #2

      Add a hyperlink rather than a label. What problems are you encountering? What don't you understand? Also, you should not be using the FONT element. Use CSS.


      I know the language. I've read a book. - _Madmatt

      T 1 Reply Last reply
      0
      • N Not Active

        Add a hyperlink rather than a label. What problems are you encountering? What don't you understand? Also, you should not be using the FONT element. Use CSS.


        I know the language. I've read a book. - _Madmatt

        T Offline
        T Offline
        Tash18
        wrote on last edited by
        #3

        Hi thanks for your reply. Actually i can display the path of the file in my page. since im using a repeater over here i wanna show the path of the file as a hyper link and when user clicks on the path the file should get downloaded.. im struggling at this point.. Any help is appreciated.. Thanx in advance, Tash

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups