How to get value from a specific cell in a gridview asp.net
And want to be multiple selection of cells in a grid . highlight with color
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Pankaj Kumar ChoudharyRank #80 · 24.4K reputationPosted Feb 22, 2015, 8:06 PM EST
rgowthamraj ramajayam
You Have two query that you want to change the color of multiple selected cell for this you can use following code
:
protected void GridViewEmployee_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
int Cell_Count=e.Row.Cells.Count;
for (int i = 0; i < Cell_Count; i++)
{
e.Row.Cells[i].Attributes.Add("onclick", "this.style.cursor='hand';this.style.backgroundColor='yellow'");
}
}
}
In Your second Query You want to find value of a specific cell
:
For this you can use following method:
f foreach (GridViewRow row in GridViewEmployee.Rows)
{
foreach (TableCell cell in row.Cells)
{
}}
Francis SusaimichaelRank #466 · 5.4K reputationPosted Feb 22, 2015, 9:00 PM EST