datagrid的使用方法

来源:百度知道 编辑:UC知道 时间:2024/06/03 16:43:17
在asp.net中的datagrid,想要任意控制每个单元格可不可以输入值,有没有这样的属性和使用方法,就是根据需要控制单元格是否可以输入值

我想要做的是根据条件可以对datagrid的每个单元格进行控制,例如:在画面上点击一个按钮,可以使其中的某些单元格可编辑,某些单元格不可编辑,感觉像是这个datagrid由很多个text框构成样的,我可以设置text的enable属性使其可或者不可编辑

想要不被编辑 可以设置 readonly 属性
/// <summary>
/// 编辑列 -----勿忘 DataBind;
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
this.GridView1.DataSource = Select();

this.TextBox2.Text = e.NewEditIndex.ToString();

this.GridView1.EditIndex = e.NewEditIndex;
this.GridView1.DataBind();
}

/// <summary>
/// 编辑 取消
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
this.GridView1.DataSource = Select();
this.GridView1.EditIndex = -1;
this.G