【发布时间】:2015-05-27 18:16:27
【问题描述】:
我正在尝试根据我为网格视图设置的某些条件禁用网格视图中的所有行,如文本框和下拉控件。我现在有了它,它可以改变颜色,但我也想锁定它或禁用这些控件我该怎么做?
protected void OnRowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
Label lblEndDate = (Label)e.Row.FindControl("lblStudyEndDate");
DateTime EndDate = DateTime.Parse(lblEndDate.Text);
if (EndDate < DateTime.Today)
{
//make all rows to read only here..
}
}
}
【问题讨论】:
-
禁用是什么意思?你想禁用复制内容吗?
-
不,我想锁定文本框,这样没有人可以输入任何内容,所以基本上让它只读。
-
那么那将是
Enabled = false看起来不像你在任何地方都在这样做你想要什么文本框是只读的,你需要更具体 -
你有没有试过:dataGridView1.ReadOnly = true; dataGridView1.Enabled = false;
-
我刚刚更新了我发布的代码