hello
when we give pre defined values in the grid by using putvalue method its working fine.
but iam using dataset here. iam binding dataset to grid. its giving the problem here.
protected void loadgrid()
{
GridWeb1.WebWorksheets[0].Cells[0, 0].PutValue("123");
GridWeb1.WebWorksheets[0].Cells[0, 1].PutValue("gdfgd dfgdf");
GridWeb1.WebWorksheets[0].Cells[1, 0].PutValue("124");
GridWeb1.WebWorksheets[0].Cells[1, 1].PutValue("fsfds");
GridWeb1.WebWorksheets[0].Cells[2, 0].PutValue("125");
GridWeb1.WebWorksheets[0].Cells[2, 1].PutValue("dsfsd fsdf");
string val = "123";
WebCells cells = GridWeb1.WebWorksheets[0].Cells;
WebCell cell;
int rowid = 0;
//Scan the second column to match the value.
for (int i = 0; i <= GridWeb1.WebWorksheets[0].Cells.MaxRow; i++)
{
cell = cells[i, 0];
if (cell.StringValue == val)
{
rowid = cell.Row;
for (int y = 0; y <= GridWeb1.WebWorksheets[0].Cells.MaxColumn; y++)
{
GridWeb1.WebWorksheets[0].Cells[rowid, y].Style.BackColor = System.Drawing.Color.Red;
}
break;
}
}
}
if i do the code like this there is no problem.
but my code is
protected void loadGridWeb()
{
SqlDataAdapter daClarifications = new SqlDataAdapter("SELECT * FROM TblDrawing where ProjectId='" + ProjectId + "'", con);
DataSet dsClarifications = new DataSet();
daClarifications.Fill(dsClarifications, "TblNote");
WebWorksheet sheet1 = this.GridWeb1.WebWorksheets[0];
sheet1.Cells.Clear();
DataTable dt = dsClarifications.Tables[0];
if (dt.Rows.Count > 0)
{
ProjectId = dt.Rows[0].ItemArray[0].ToString();
}
sheet1.DataSource = dsClarifications;
//sheet1.CreateAutoGenratedColumns();
sheet1.DataBind();
string val = DrawingId;
WebCells cells = GridWeb1.WebWorksheets[0].Cells;
WebCell cell;
int rowid = 0;
//Scan the second column to match the value.
for (int i = 0; i <= GridWeb1.WebWorksheets[0].Cells.MaxRow; i++)
{
cell = cells[i, 10];
if (cell.StringValue == val)
{
rowid = cell.Row;
for (int y = 0; y <= GridWeb1.WebWorksheets[0].Cells.MaxColumn; y++)
{
GridWeb1.WebWorksheets[0].Cells[rowid, y].Style.BackColor = System.Drawing.Color.Red;
}
break;
}
}
}
when i use this code its displaying alternate rows in red color.