开发者

DataGridTextboxcolumn readonly based on condition

I am using c# compact framework. vs 200开发者_高级运维5. I am binding a datatable to datagrid. I have a placed datagridTEXTBOXCOULUMN as one column of the Datagrid. I need to make that column readonly based on the value in the other column.

for eg. If Cid column value is 2, i need to make datagridTEXTBOXCOULUMN read only true. If Cid column value is 4, i need to make datagridTEXTBOXCOULUMN read only false. this needs to be done on binding the data to datagrid.

Is there any event in which i can do this i have this property datagridTEXTBOXCOULUMN.readonly

in which event i can do this based on condition

thanks


You can use the RowDataBound event of the grid,

 protected void Grid_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            TextBox textBox = e.Row.FindControl("TextBoxID") as TextBox;

            if(<<Your condition>>)
            {
                textBox.Enabled = false;
            }
        }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜