Display MS Word in a Datagrid from SQL 2000 Database

Webdude

Member
Joined
Jul 16, 2007
Messages
5
Programming Experience
Beginner
Hi,

I have MS Word documents in a SQL 2000 database, and I would like to display them in a datagrid. I have a feeling it is not to difficult, but I am not sure how to do this. Hopefully there is someone that has done this before and can help me out.

Thanks,
Webdude
 
u would like to display the content of the word document in the datagrid? what are u thinking about? =s
 
Hi Alander,

I want to use a datagrid to display the Microsoft Word documents that I have stored in our SQL 2000 database. The header information will be as follows;

|File Name | Last Write Time | File Size
filename_060616.doc | 6/13/07 | 35,328 bytes
filename_060625.doc | 6/23/07 | 37,328 bytes
filename_070725.doc | 7/23/07 | 37,328 bytes

So I guess I should have said that I want to link the binary files(MS Word) that are in the SQL database in a datagrid. Example of how I want it to look is above.

Thanks,
Webdude
 
I will give it a try and let you know if it works or not.

You'll need to use TableStyles and DataGridColumnStyles. Here is an example of a DataGrid that might display File Name, File Size, and Last Modified date:

/* The DataGridTableStyle AllowSorting property
* overrides the DataGrid AllowSorting property. */

DataGridTableStyle style = new DataGridTableStyle();
style.MappingName = dataSet.FileInfo.TableName;
style.AllowSorting = false;
style.AlternatingBackColor = Color.AliceBlue;
style.HeaderForeColor = Color.Blue;
style.DataGrid = this.dataGrid1;

/* This works for most text columns. I am displaying a a file name
* so I set the ReadOnly property to true. I also set the
* NullText property to get rid of the "null" that is displayed by
* default. */

DataGridTextBoxColumn textBoxColumn = new DataGridTextBoxColumn();
textBoxColumn.MappingName = "FileName";
textBoxColumn.Format = "";
textBoxColumn.FormatInfo = null;
textBoxColumn.HeaderText = "File Name";
textBoxColumn.NullText = "";
textBoxColumn.ReadOnly = true;
textBoxColumn.Width = 350;
style.GridColumnStyles.Add(textBoxColumn);

/* I use the Format property to display the File Size in KB
* rather than Bytes by adding that extra comma to the left
* of the period in my format string. */

DataGridTextBoxColumn numberColumn = new DataGridTextBoxColumn();
numberColumn.MappingName = "FileSize";
numberColumn.Alignment = HorizontalAlignment.Right;
numberColumn.Format = "#,###,. 'KB '";
numberColumn.FormatInfo = null;
numberColumn.HeaderText = "Size in KB";
numberColumn.NullText = "";
numberColumn.ReadOnly = true;
numberColumn.Width = 75;
style.GridColumnStyles.Add(numberColumn);

/* I use a custom date format in this Format property to display
* the date in a typically European style (e.g. 13 SEP 2004) and
* append the time in hours and minutes only. The 'tt' after the
* time will display 'am' or 'pm'. */

DataGridTextBoxColumn dateTimeColumn = new DataGridTextBoxColumn();
dateTimeColumn.MappingName = "LastModified";
dateTimeColumn.Alignment = HorizontalAlignment.Right;
dateTimeColumn.Format = "dd MMM yyyy hh:mm tt";
dateTimeColumn.FormatInfo = null;
dateTimeColumn.HeaderText = "Last Modified";
dateTimeColumn.NullText = "";
dateTimeColumn.ReadOnly = true;
dateTimeColumn.Width = 150;
style.GridColumnStyles.Add(dateTimeColumn);

/* Always add the the TableStyle to the DataGrid AFTER
* the ColumnStyles have been added to the TableStyle. */
this.dataGrid1.TableStyles.Add(style);
 
Hi Again,

It looks like the above code is for designing forms not a datagrid on a web page. I guess I need to look for a different solution.

Oh well...


Webdude
 
Last edited:
It looks like the above code is for designing forms not a datagrid on a web page.
Posting to appropriate forum/section does help getting you relevant advice, thread moved to ASP.Net section.
 
Back
Top