0

データベースからデータをフェッチしているこのようなグリッドビューがあり、ヘッダー列がありません

ここに画像の説明を入力してください

このグリッドビューにはヘッダーがありません。これらは行のみです。問題は、その列をフォーマットしたいということです。

ここで見ることができる31 DECのは月曜日なので、日付が月曜日である各列をフォーマットしたい。最初の行の月曜日であるその列の色を変更したい。だから、誰でもc#でこれを行うアイデアを教えてくれる。

4

2 に答える 2

2

これは、一致するセルに色を付けるのに役立ちます

protected void grid_RowDataBound(Object sender, GridViewRowEventArgs e) 
{
  if (e.Row.RowType = DataControlRowType.DataRow)
  {
    //Check your condition here
    //Get Id from here and based on Id check value in the 
    //underlying dataSource Row Where you have "Done" column Value
    // e.g.
    // (gridview.DataSource as DataTable), now you can find your row and cell 
    // of "Done"
    If(Condition True)
    {
        e.Row.BackColor = Drawing.Color.Red  // your color settings 
    }
   }
}
于 2013-01-09T09:05:51.343 に答える
0

私は自分の答えをこのように見つけました

foreach (TableCell cell in e.Row.Cells) {
                    if (cell.Text != "-1" && cell.Text != "Cotton Arrival") {

                        char[] c = new char[7];
                        c = cell.Text.ToCharArray();

                        string datee = c[0].ToString()+c[1].ToString() ;
                        string monthh = c[2].ToString() + c[3].ToString();
                        string yearr = c[4].ToString() + c[5].ToString() + c[6].ToString() + c[7].ToString();

                        DateTime dtime = new DateTime(Convert.ToInt32(yearr),Convert.ToInt32(monthh),Convert.ToInt32(datee));

                        string day = dtime.DayOfWeek.ToString() ;

                        if (day.ToLower() == "monday") 
                        {
                            GridView1.Columns[count].ItemStyle.CssClass = "monday";
                            GridView2.Columns[count].ItemStyle.CssClass = "monday";
                            GridView3.Columns[count].ItemStyle.CssClass = "monday";
                            GridView4.Columns[count].ItemStyle.CssClass = "monday";
                            break;
                        }
                        count ++;
                    }
                }
于 2013-01-09T12:29:04.357 に答える