Tuesday, November 24, 2009

GridView with CSS

<asp:GridView ID="gvShowCourses" runat="server" AutoGenerateColumns="false" CssClass="Grid" AlternatingRowStyle-CssClass="AlternatingItem"></asp:GridView>
and in the css file add the following style :

.Grid{ border:none; color:#333333; width:100%; }
.Grid tr{ vertical-align:top;}
.Grid th {background-color:#990000;font-weight:bold;color:White;padding:5px;}
.Grid td {background-color:#eeeeee;font-weight:normal;color:#333333;padding:5px;}
.AlternatingItem td{background-color:#FFFFFF;font-weight:normal;color:#333333;padding:5px;}

Difference between textarea and all other controls

When disabling the controls on the form.. remember:

All the other controls like text and button and dropdrownlist, you set Enabled= false.

But with textarea, you set Disabled = true;

Do not know why that is different.

Clear dropdown index...

Finally found the solution to the following error :

Server Error in '/' Application.
Cannot have multiple items selected in a DropDownList.Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: Cannot have multiple items selected in a DropDownList.

Solution:
You just set the dropdownlist.SelectedIndex = -1;

Thats all folks !!!