I want to retrieve attachments from a sharepoint list. But don't really know how to, any suggestions?
SOLVED: Check code under picture.
public void MyData(string prod)
{
SPWeb web = SPContext.Current.Web;
SPList myList = web.Lists.TryGetList("Extern Products");
if (myList!=null)
{
SPQuery query = new SPQuery();
query.Query = string.Format(
"<Where><BeginsWith><FieldRef Name='ProductNumber' />" +
"<Value Type='Text'>{0}</Value></BeginsWith></Where>", prod);
query.RowLimit = 10;
SPListItemCollection items = myList.GetItems(query);
foreach (SPListItem listItem in items)
{
TextBox_NameList.Text = listItem["Title"] != null ? listItem["Title"].ToString() : string.Empty;
TextBox_ListPriceList.Text = listItem["ListPrice"] != null ? listItem["ListPrice"].ToString() : string.Empty;
TextBox_ProdNumList.Text = listItem["ProductNumber"] != null ? listItem["ProductNumber"].ToString() : string.Empty;
TextBox_ColorList.Text = listItem["Color"] != null ? listItem["Color"].ToString() : string.Empty;
TextBox_MoreInformationList.Text = listItem["MoreInformation"] != null ? listItem["MoreInformation"].ToString() : string.Empty;
//FileUpload_PicList.PostedFile.ContentType = listItem["Attachments"] != null ? listItem["Attachment"].ToString() : string.Empty;
HiddenField_ID.Value = listItem["ID"].ToString();
}
}
}
protected void Button_Edit_Click(object sender, EventArgs e)
{
if(TextBox_Search.Text == string.Empty)
{
Label_ExtensionList.Text = "Who haven't selected anything!";
}
else if (ListBox_List.SelectedItem != null)
{
MyData = ListBox_List.SelectedItem.Value;
}
}

foreach (SPListItem listItem in items)
{
HiddenField_ID.Value = listItem["ID"].ToString();
TextBox_NameList.Text = listItem["Title"] != null ? listItem["Title"].ToString() : string.Empty;
TextBox_ListPriceList.Text = listItem["ListPrice"] != null ? listItem["ListPrice"].ToString() : string.Empty;
TextBox_ProdNumList.Text = listItem["ProductNumber"] != null ? listItem["ProductNumber"].ToString() : string.Empty;
TextBox_ColorList.Text = listItem["Color"] != null ? listItem["Color"].ToString() : string.Empty;
TextBox_MoreInformationList.Text = listItem["MoreInformation"] != null ? listItem["MoreInformation"].ToString() : string.Empty;
**foreach (string fileName in listItem.Attachments)
{
SPFile file = listItem.ParentList.ParentWeb.GetFile(
listItem.Attachments.Count + fileName);
ListBox_Attachment.Items.Add(file.ToString());
}**
}