GridView

 

GridView控件外觀知識點
 GridView控件可以通過行和列來控制外觀樣式。
 整體外觀控制:佈局、分頁、外觀
 行外觀控制:項、交替項、編輯項、選中項、頁眉、頁腳、分頁、空數據項
eg:
        if (e.Row.RowType != DataControlRowType.DataRow)
            return;

        LinkButton lbtn = e.Row.Cells[6].Controls[0] as LinkButton;  //除模板列之外的特殊列,使用單元的Controls集合去訪問
        //HyperLink link = e.Row.Cells[1].Controls[0] as HyperLink;
        string sid = e.Row.Cells[0].Text;  //普通綁定列,通過單元格的Text去訪問
        Image img = e.Row.Cells[5].FindControl("Image1") as Image;  //適合在模板列中查找
        if (lbtn != null)
        {
            lbtn.Attributes.Add("onclick", "return confirm('確信要刪除編號爲" + sid + "的" + link.Text + "嗎?圖片地址爲:" + img.ImageUrl + "');");
        }

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