2014年7月13日 星期日

[RESOLVED] ForeColor of a gridview row 's text, if that row is disabled.


How to change the ForeColor of a gridview's row 's text, if that row is disabled.

(some of the rows are enabled and some are disabled.)


I gave this code in the item the itemDatabond


e.Item.ForeColor = System.Drawing.Color.Blue

e.Item.BackColor = System.Drawing.Color.LightGray

e.Item.Enabled = False




But it is not working because that row is disabled and very hard to read the text in the disabled row.


Thanks




But it is not working because that row is disabled and very hard to read the text in the disabled row.


What does this mean?


If you are using IE, then it changes the color based on if a control is disabled.  If you lookin in FF or Chrome for example, the your colors will take.


You can set the row to ReadOnly instead of Disabled, then your colors should take.



Try this CSS :


disabled style has it's own than normal style


[disabled]
{
color:#933;
background-color:#ffc;
}

http://www.w3schools.com/cssref/sel_disabled.asp



meaning the code I added is working. ( it is now showing the blue forecolor for the disabled row's text)


e.Item.ForeColor = System.Drawing.Color.Blue

e.Item.BackColor = System.Drawing.Color.LightGray

e.Item.Enabled = False



And i did not see any readonly property for e.Item for the row either. I am trying to do it throgh the code rather than stylesheet.


Any other suggestions?





Jaypal



And i did not see any readonly property for e.Item for the row either. I am trying to do it throgh the code rather than stylesheet.


Any other suggestions?





Hi,


There is no readonly property for the row, you have to set the cells in the row to as readonly:


TextBox chkVal = ((TextBox)row.FindControl("TextBox1"));

chkVal.ReadOnly = false;


I try your way to set the forecolor for the disable row, it can work well.


Hope it can help you.


Best Regards,

Amy Peng 




沒有留言:

張貼留言