gridView RowDataBound事件詳解

        //控件是是行
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            //奇數和偶數行是編輯狀態
            if (e.Row.RowState == DataControlRowState.Edit ||
                e.Row.RowState == (DataControlRowState.Alternate | DataControlRowState.Edit))
            {

//在滿足條件的行中找控件

DropDownList ddlReadiness = e.Row.FindControl("drpListNominationTime") as DropDownList;
Label lblReadiness = e.Row.FindControl("lblReadiness") as Label;

}

}

//是GridView頭部行,可以實現全選與全部選功能 checkbox

 if (e.Row.RowType == DataControlRowType.Header)
        {
            for (int i = 0; i < e.Row.Cells.Count; i++)
            {
                for (int j = 0; j < e.Row.Cells[i].Controls.Count; j++)
                {
                    if (e.Row.Cells[i].Controls[j] is CheckBox)
                    {
                        CheckBox chk = (CheckBox)e.Row.Cells[i].Controls[j];
                        chk.Attributes.Add("onclick", "ClickCheckAllItem(this)");
                    }
                }
            }
        }

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章