摘要:GridView RowDataBound的取出裡面的控制項
若使用e.Row就可以抓到每一欄的GridViewRow
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow) {
//Response.Write(e.Row.ToString());
GridViewRow row = (GridViewRow)e.Row;
RadioButtonList rrl1 = (RadioButtonList)row .FindControl("RadioButtonList1");
//RadioButtonList rrl2 = (RadioButtonList)GridView1.Rows[e.Row.RowIndex].FindControl("RadioButtonList1"); 寫這樣反而多此一舉
if (row.Cells[4].Text == "女"){
// if (e.Row.Cells[4].Text == "女") {
e.Row.Cells[4].ForeColor = System.Drawing.Color.Red;
}
}
}