|
Subject:
|
Opening and/or Editing Document file in ASP.NET 2.
|
|
Posted By:
|
akhilhp
|
Post Date:
|
12/20/2006 11:35:43 PM
|
Dear All,
I am new to ASP.Net 2.0(or say to asp.net itself) I have been recently assigned a project. In this subordinate staff will prepare reports for recieved applications from the public and the officer will take decision depending upon the report submitted for a particular application. For report writing we are planning to use the MS-Word. I have been able to store the MS Word Document to the database through ASP.NET 2.0. Now I am stuck for how can I open the stored document for the Officer. In simple way I want to open a word document from a web page created using ASP.NET 2.0. Can anybody help me.
|
|
Reply By:
|
bonekrusher
|
Reply Date:
|
12/21/2006 2:24:17 PM
|
How do you plan on accessing the file?
|
|
Reply By:
|
akhilhp
|
Reply Date:
|
12/21/2006 11:42:20 PM
|
I wish that there can be a button on the page for "View Report" and when the officer clicks it the report document should open (as the report presently being uploaded is in Word format so the report should open in the Word)
But I am not rigid in it. I simply want that there should be some criteria in which the subordinate staff can write and save report corresponding to an application and the officer should be able to view this report when he wants to make a decision on the application. I previously used the text field in SQL Table and allowed to enter the report in textbox, which then was saved to the text field of the table. While making decision the report was shown in a label taking the report from the text field of the table. But my Group head rejected this design. He is insisting that the report should be allowed to be written in a document editor.
|
|
Reply By:
|
bonekrusher
|
Reply Date:
|
12/27/2006 1:13:05 PM
|
If you have a grid view bound to your database, you can add a hyperlink field which is bound to the table field which holds the path and file name. When clicked they can open the file, edit and save it.
|
|
Reply By:
|
akhilhp
|
Reply Date:
|
1/3/2007 1:23:36 AM
|
It did not work dear. As the User will be updating new documents every day. Also since the documents are being uploaded from client side the file path and name cannot be sent to the table field. I tried to get the file from table and save it on server and give the hyperlink that address but it again didnot work. I am using following procedure : Con = New SqlConnection(MainConStr) SQLStr = "Select ruid, report, 'File Name' as reportnm from case_initial where court_cd = 'C001'" Dim b, i As Integer Dim sqladp As New SqlDataAdapter(SQLStr, Con) Dim ds As New DataSet b = sqladp.Fill(ds, "Try") Dim MyData() As Byte Dim fs As FileStream For i = 0 To ds.Tables("Try").Rows.Count - 1 If Not IsDBNull(ds.Tables("Try").Rows(i).Item(1)) Then MyData = ds.Tables("Try").Rows(i).Item(1) Dim k As Long k = UBound(MyData) fs = New FileStream(Server.MapPath(".\Created" & i & ".doc"), FileMode.OpenOrCreate, _ FileAccess.Write) fs.Write(MyData, 0, k) ds.Tables("Try").Rows(i).Item(2) = Server.MapPath(".\Created" & i & ".doc").ToString fs.Close() fs = Nothing End If Next Con.Close() Con = Nothing
Me.GridView1.DataSource = ds Me.GridView1.DataBind() where my gridview declaration is : <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" Width="370px"> <Columns> <asp:BoundField DataField="ruid" HeaderText="Appno" ReadOnly="True" SortExpression="ruid" /> <asp:HyperLinkField DataNavigateUrlFields="reportnm" DataTextField="reportnm" HeaderText="File" /> </Columns> </asp:GridView>
|