My gridview code :
<columns>
<asp:boundfield runat="server" DataField="title" HeaderText="Title"></asp:boundfield>
<asp:HyperLinkField DataNavigateUrlFields="link" ItemStyle-HorizontalAlign="center" DataTextField="link" HeaderText="Download File" />
</columns>
My Code-behind :
dt.Columns.Add("title");
dt.Columns.Add("link");
while (item.Read())
{
DataRow dr = dt.NewRow();
dr["title"] = item["title"];
dr["link"] = "/download.cshtml?id="+ item["link"];
dt.Rows.Add(dr);
}
grdData.DataSource = dt;
grdData.DataBind();
My Grid view shows up Like :
i want it to show "Download" instead of full link, how can i do that ?
You can build HTML inside the datarow. For example:
dr["link"] = "<a href='"+ "/download.cshtml?id=" + item["link"] + "'>Download</a>";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.