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
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Francis SusaimichaelPosted Feb 23, 2015, 2:00 AM
Pankaj Kumar ChoudharyPosted Feb 23, 2015, 1:06 AM
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)
{
}}