CssClass="ProductListing"
Width="100%">
No Announcements Available
<%# Eval("Title") %>
<%# Eval("Announcements") %>
<%# string.Format("{0:dd-MMM-yyyy}", Eval("DateCreated"))%>
i Highlighted the templatefield which i wanted to change, i would like to set visible to false for btnEdit and btnDelete if userType = customer. I need to do it in the Codebehind can anyone help me? i know i just need to declare some stuff before doing the if else but i dont know how to :( any help is appreciated so thanks in advance :)
Blocked AccountPosted Jul 25, 2011, 7:10 AM
Hi,
Write the code in RowDataBound event.
protected void gvAnnouncement _RowDataBound(object sender, GridViewRowEventArgs e){
if (e.Row.RowType == DataControlRowType.DataRow)
{
Button ButtonEdit = (Button)e.Row.FindControl("btnEdit ");
Button ButtonDelete = (Button)e.Row.FindControl("btnDelete ");
//Check the User Type Here
If(UserType="Admin")
{
ButtonEdit.Visible = true;
ButtonDelete.Visible = true;
}
Else
{
ButtonEdit.Visible = false;
ButtonDelete.Visible = false;
}
}
}
Blocked AccountPosted Jul 25, 2011, 11:34 PM
Toh Zuan YiPosted Jul 25, 2011, 9:38 PM