开发者

DataGridTextboxcolumn readonly based on condition

开发者 https://www.devze.com 2023-03-16 19:53 出处:网络
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

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

精彩评论

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

关注公众号