gridview塞textBOX
protected void GridView_RowDataBound(object sender, GridViewRowEventArgs e)
{
//判斷是否在編輯模式
if ((e.Row.RowState & DataControlRowState.Edit) != 0)
{
//
TextBox tb1 = (TextBox)e.Row.Cells[3].Controls[0];
TextBox tb2 = (TextBox)e.Row.Cells[4].Controls[0];
TextBox tb3 = (TextBox)e.Row.Cells[12].Controls[0];
tb1.Attributes.Add("maxlength", "12");
tb2.Attributes.Add("maxlength", "12");
tb3.Attributes.Add("maxlength", "12");
//
tb1.Attributes.Add("class", "TextBox");
tb2.Attributes.Add("class", "TextBox");
tb3.Attributes.Add("class", "TextBox");
//屬性設置
tb1.Width = 70;
tb2.Width = 70;
tb3.Width = 70;
tb1.Enabled = false;
tb7.Enabled = false;
}
}
沒有留言:
張貼留言