For one of the columns "startdate" in my gridview, if the user has correct permissions, I want to add an edit icon to open a calendar which allows the user to edit the date.
I have the following code to add the image to the column, but it's replacing the date rather than appending the image after the date.
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (System.Web.Security.Roles.IsUserInRole(Security.GetUserName(true, true), "UpdateStartDate"))
{
HyperLink hl = new HyperLink();
// hl.Text = e.Row.Cells[6].Text;
hl.ImageUrl = "../images/pencil.gif";
e.Row.Cells[6].Controls.Add(hl);
}
}
}
The gridview column
<asp:BoundField HeaderText="Start Date" DataField="start_dt" DataFormatString="{0:d}" SortExpression="start_dt" ReadOnly="true" />