グリッドビューの「startdate」列の1つで、ユーザーが正しい権限を持っている場合、編集アイコンを追加してカレンダーを開き、ユーザーが日付を編集できるようにします。
列に画像を追加するための次のコードがありますが、日付の後に画像を追加するのではなく、日付を置き換えています。
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);
}
}
}
グリッドビュー列
<asp:BoundField HeaderText="Start Date" DataField="start_dt" DataFormatString="{0:d}" SortExpression="start_dt" ReadOnly="true" />