Ramco Ramco

Ramco Ramco

  • 469
  • 2.8k
  • 393.8k

LinkButton Color

Jul 14 2022 4:51 AM

Hi 

     I have used below code & it is working . I want LinkButton control should appear in Circle & its color should gets changed

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 = 2; i < e.Row.Cells.Count; i++)
{
var row = (DataRowView)e.Row.DataItem;
var currentPerson = row[0].ToString();
var currentDate = row.DataView.Table.Columns[i];
var commandArgument = currentPerson + ":" + currentDate;
LinkButton button = new LinkButton();
button.Text = row[i].ToString();
button.CommandName = "Select";
button.CommandArgument = commandArgument;
button.OnClientClick = "GetModuleData(this)";
if (row[i].ToString() == "A")
button.ForeColor = Color.Red;
if (row[i].ToString() == "S")
button.ForeColor = Color.Green;
//{ Text = row[i].ToString(), CommandName = "Select", CommandArgument = commandArgument, CssClass = "badge badge-warning badge-pill", OnClientClick = "GetModuleData(this)" };
e.Row.Cells[i].Controls.Add(button);

e.Row.Cells[i].HorizontalAlign = HorizontalAlign.Center;
}
}
catch (Exception ex)
{
Utility.SaveErrorLog(ex.Message, System.IO.Path.GetFileName(Request.Path), System.Reflection.MethodBase.GetCurrentMethod().Name, Convert.ToInt32(hdfLoginCode.Value));
ShowMessage("Oops...", ex.Message, "error");
}
}

Thanks


Answers (1)