|
如何在WebGridView自行帶值的方法。 |
|
|
可以利用RowDataBound的事件來設定欄位的初值, 如下: protected void WebGridView1_RowDataBound(object sender, GridViewRowEventArgs e) { //做Default操作(Insert時使用) if (e.Row.RowType == DataControlRowType.Footer && WebGridView1.ShowFooter) { Control ctrl = e.Row.FindControl("TextBox1"); if (ctrl != null && ctrl is TextBox) { TextBox txt = (TextBox)ctrl; txt.Text = "abc"; } } //做Default操作(Update時使用) if (e.Row.RowType == DataControlRowType.DataRow) { Control ctrl = e.Row.FindControl("TextBox1"); if (ctrl != null && ctrl is TextBox) { TextBox txt = (TextBox)ctrl; txt.Text = "abc"; } } }
|
|
|