Hi georgeacuster8937,
Refer:
Using IF ELSE condition in BoundField column in ASP.Net GridView
I have used above article and created a Sample for you.
HTML
<asp:GridView ID="gvAttendance" runat="server" AutoGenerateColumns="false" OnRowDataBound="OnRowDataBound">
<Columns>
<asp:BoundField DataField="Id" HeaderText="Id" />
<asp:BoundField DataField="Name" HeaderText="Name" />
<asp:BoundField DataField="Attendance" HeaderText="Attendance" />
</Columns>
</asp:GridView>
Namespaces
C#
using System.Data;
Code
C#
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
DataTable dt = new DataTable();
dt.Columns.AddRange(new DataColumn[3] { new DataColumn("Id"), new DataColumn("Name"), new DataColumn("Attendance") });
dt.Rows.Add(1, "John Hammond", "A");
dt.Rows.Add(2, "Mudassar Khan", "P");
dt.Rows.Add(3, "Suzanne Mathews", "P");
dt.Rows.Add(4, "Robert Schidner", "A");
dt.Rows.Add(5, "", "");
gvAttendance.DataSource = dt;
gvAttendance.DataBind();
}
}
protected void OnRowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
TableCell AttendanceCell = e.Row.Cells[2];
if (AttendanceCell.Text == "A")
{
AttendanceCell.Text = "Absent";
}
else if (AttendanceCell.Text == "P")
{
AttendanceCell.Text = "Present";
}
else
{
AttendanceCell.Text = "No Record ";
}
}
}
Screenshot