0

列の値を左側に揃える このコードを使用しています

protected void GridView1_RowDataBound(object o, GridViewRowEventArgs e)
{
   //Assumes the Price column is at index 4
   if (e.Row.RowType == DataControlRowType.DataRow)
        e.Row.Cells[2].HorizontalAlign = HorizontalAlign.Right;
}

しかし、私はこのようにグリッドを制御しているので、取得できません

 protected void GridView1_DataBound1(object sender, EventArgs e)
 {
    for (int rowIndex = grdtcwisetarget.Rows.Count - 2; rowIndex >= 0; rowIndex--)
    {
       GridViewRow gvRow = grdtcwisetarget.Rows[rowIndex];
       GridViewRow gvPreviousRow = grdtcwisetarget.Rows[rowIndex + 1];
       for (int cellCount = 0; cellCount < 2;cellCount++)
       {
           if (gvRow.Cells[cellCount].Text == gvPreviousRow.Cells[cellCount].Text)
           {
               if (gvPreviousRow.Cells[cellCount].RowSpan < 2)
               {
                  gvRow.Cells[cellCount].RowSpan = 2;
               }
               else
               {
                  gvRow.Cells[cellCount].RowSpan =
                  gvPreviousRow.Cells[cellCount].RowSpan + 1;
               }
             gvPreviousRow.Cells[cellCount].Visible = false;
           }
         }
       }
    }
4

2 に答える 2