Windows Develop Bookmark and Share   
 index > Windows Forms General > Attachments in a grid view and unwanted items in outer xml
 

Attachments in a grid view and unwanted items in outer xml

Hi

1. I'm retriving sharepoint list data in an application. These list items are shown in a DataGridView. I have a list which have links to attachments. How can I  view that atachments through a link in the DataGridView.

2. I'm using the GetListItems in an XmlNode. And then into a StringReader. I want only the columns that are in the List because the OuterXml and InnerXml gives you information which i don't want. How can i remove them?

This is the code where i'm getting the xml so you can understand better my project:


System.Xml.XmlDocument xdoc = new System.Xml.XmlDocument();

XmlNode ndListItems = service.GetListItems(listName, viewName, null, null, rowLimit, null, null);



System.IO.StringReader StringReader = new System.IO.StringReader(ndListItems.InnerXml);

XmlTextReader TextReader = new XmlTextReader(StringReader);

DataSet DataSet = new DataSet("resultDataSet");

DataSet.ReadXml(TextReader);



if (DataSet != null && DataSet.Tables.Count >= 2)

{

    this.dataGridView1.DataSource = DataSet.Tables[1];

}

Thanks in advice for your help
Keyaa
keyaa  Tuesday, October 06, 2009 7:20 AM

Hi keyaa,

 

1.    I'm retrieving sharepoint list data in an application. These list items are shown in a DataGridView. I have a list which have links to attachments. How can I  view that attachments through a link in the DataGridView.

Reply: I am not familiar with attachments in DataGridView, but I can provide some ideas. To show the value of large size on a DataGridView, we often add another form to show the data and handle the CellDoubleClick event of the DataGridView to show the form.

1)    If the data is text, we can add a TextBox control and set its Multiline property to true onto the form. The Text property of TextBox contains the text.
Link: http://msdn.microsoft.com/en-us/library/system.windows.forms.textbox.aspx

2)    If the data is a picture, we can add a PictureBox control onto the form to show the picture. The Image property contains the image.

Link:
http://msdn.microsoft.com/en-us/library/system.windows.forms.picturebox.aspx

3)    If the data is a document of type RTF, we can add a RichTextBox control onto the form to show the document. The Rtf property contains the document.

Link:
http://msdn.microsoft.com/en-us/library/system.windows.forms.richtextbox.aspx

2.    I'm using the GetListItems in an XmlNode. And then into a StringReader. I want only the columns that are in the List because the OuterXml and InnerXml gives you information which i don't want. How can i remove them?

Reply: Based on my understanding,  you only need to load some of the nodes, the text or attributes of which are equal to some certain values. We can create a XPath string and take it as a parameter to call the SelectNodes method to ge the filted nodes. This is a walkthrough:
http://msdn.microsoft.com/en-us/library/d271ytdx(VS.80).aspx
This is the details about SelectedNodes method:
http://msdn.microsoft.com/en-us/library/hcebdtae.aspx

These are some documents about XPath:
http://msdn.microsoft.com/en-us/library/ms256115.aspx
http://msdn.microsoft.com/en-us/library/ms256086.aspx

Regards,
Aland Li


Please mark the replies as answers if they help and unmark if they don't. This can be beneficial to other community members reading the thread.
Aland Li  Thursday, October 08, 2009 7:59 AM

You can use google to search for other answers

Custom Search

More Threads

• Dialog ZOrder Behind Parent on Win98 / NT
• FileName without Path in OpenFileDialog
• Dock Style
• Making a button look like a combobox button... sort of
• Inheriting user control from another user control (Windows application)
• Remove Left Padding of "0"
• Images and Forms
• Win Form & Web Form Control Update from a thread in Assembly
• XP Look and Feel - Manifest Not Working With VS 2005
• [C#] DragDrop to Desktop/Explorer