Hyper Link in datagrid to download a file
-
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
-
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
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
-
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
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