Hi
I have attached image and below is the code . Button getting created on first student Hrithvi but not getting created on Srinithya
protected void gr_RowDataBound(object sender, GridViewRowEventArgs e)
{
try
{
if (e.Row.RowType != DataControlRowType.DataRow)
return;
e.Row.Cells[0].HorizontalAlign = HorizontalAlign.Center;
for (int i = 8; i < e.Row.Cells.Count-1; i++)
{
string cellValue = e.Row.Cells[i].Text;
var row = (DataRowView)e.Row.DataItem;
// Create a new LinkButton control
LinkButton button = new LinkButton();
button.Text = cellValue;
//button.OnClientClick = "showModalPopup('" + cellValue + "'); return false;"; // assuming there is a JavaScript function named 'showModalPopup' that takes the cell value as a parameter
// Replace the text of the cell with the LinkButton control
e.Row.Cells[i].Controls.Clear();
if (row[i].ToString().ToUpper() == "A")
{
button.CssClass = "badge badge-danger";
}
else if (row[i].ToString().ToUpper() == "B")
{
button.CssClass = "badge badge-warning";
}
else if (row[i].ToString().ToUpper() == "ND")
{
button.CssClass = "badge badge-secondary";
button.OnClientClick = "return false;";
}
else if (row[i].ToString().ToUpper() == "D")
{
button.CssClass = "badge badge-success";
}
else if (row[i].ToString().ToUpper() == "S")
{
button.CssClass = "badge badge-info";
}
else if (row[i].ToString().ToUpper() == "HB")
{
button.CssClass = "badge badge-primary";
}
e.Row.Cells[i].Controls.Add(button);
}
}
}
