in aspx page:
<asp:GridView ID="GridView1" runat="server" ShowHeader="false" Visible="false" AutoGenerateColumns="false">
<Columns>
<asp:HyperLinkField DataTextField="Title" DataNavigateUrlFields="URL"></asp:HyperLinkField>
</Columns>
</asp:GridView>
in code behind:
try
{
SPWeb oWeb = SPContext.Current.Web;
SPListItem nitem = oWeb.Lists["UrListName"].GetItemById(id);
DataTable table = new DataTable();
table.Columns.Add("Title", typeof(string));
table.Columns.Add("URL", typeof(string));
foreach (String attachmentname in nitem.Attachments)
{
DataRow row = table.NewRow();
row["Title"] = attachmentname;
row["URL"] = nitem.Attachments.UrlPrefix + attachmentname;
table.Rows.Add(row);
}
table.AcceptChanges();
GridView1.Visible = true;
GridView1.DataSource = table.DefaultView;
GridView1.DataBind();
}
catch (Exception ex)
{
//throw ex;
}
<asp:GridView ID="GridView1" runat="server" ShowHeader="false" Visible="false" AutoGenerateColumns="false">
<Columns>
<asp:HyperLinkField DataTextField="Title" DataNavigateUrlFields="URL"></asp:HyperLinkField>
</Columns>
</asp:GridView>
in code behind:
try
{
SPWeb oWeb = SPContext.Current.Web;
SPListItem nitem = oWeb.Lists["UrListName"].GetItemById(id);
DataTable table = new DataTable();
table.Columns.Add("Title", typeof(string));
table.Columns.Add("URL", typeof(string));
foreach (String attachmentname in nitem.Attachments)
{
DataRow row = table.NewRow();
row["Title"] = attachmentname;
row["URL"] = nitem.Attachments.UrlPrefix + attachmentname;
table.Rows.Add(row);
}
table.AcceptChanges();
GridView1.Visible = true;
GridView1.DataSource = table.DefaultView;
GridView1.DataBind();
}
catch (Exception ex)
{
//throw ex;
}