March 2008 Entries

Articles about Working with multiple checkboxes in GridView

I wanted to have multiple checkboxes in GridView . Below are a few links, that I've read before implemented my user control. Checking All CheckBoxes in a GridView Using Client-Side Script and a Check All CheckBox Storing and Maintaining DataGrid CheckBox Values - Selecting, Confirming & Deleting Multiple Checkbox Items In A DataGrid/GridView Implementing ITemplate as Anonymous Method Creating Web Server Control Templates Dynamically by implementing the ITemplate interface e.g. CheckBoxTemplate ......

Validation of viewstate MAC failed when using asp.timer to trigger UpdatePanel

I have a page with UpdatePanel and ASP:Timer, that refreshs the UpdatePanel every minute. It was noticed that after new release after the first refresh any postback causes "Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster." I've searched Google and found that this error is quite common. Below there are just a few suggestions: I do ......

Create multi-row gridview Header with buttons in header

I found a few articles , that try to create multi-row gridview Header All solutions suggest to create extra DataViewRow(s) of a type DataControlRowType.Header on RowDataBound event. However on Postback DataBind usually is not called, and so RowDataBound event will not occur. It means that the second header will not be recreated on Postback -not good. Discussion GridView - trouble with double ......

Remove empty lines in text using Visual Studio.

Visual Studio has ability to delete empty lines in replace operation using regular expressions. 1.Click Ctrl-H (quick replace) 2. Tick "Use Regular Expressions" 3. In Find specify ^$\n 4. In Replace box delete everything. 5 Click "Replace All" All empty lines will be deleted. Regular expression for empty line consist of Beginning of line ^ End of line $ Line break \n Note that normally in Windows an end of line indicated by 2 characters CRLF - Carriage Return (CR, ASCII 13, \r) Line Feed (LF, ASCII ......

Unable to set Gridview HyperLinkField Header using DataBinding

I've tried to set Gridview HyperLinkField Header text to some value using DataBinding <%# Eval("Rating") %> ,but it caused error: 'Gridview :Databinding expressions are only supported on objects that have a DataBinding event. System.Web.UI.WebControls.H... does not have a DataBinding event. I had to assign Gridview HyperLinkField Header programmatically using RowDataBound event handler ......

AppendIfNotContains string helper method

I've created a helper function, that allows me to set extra CSS class name(space separated) public static string AppendIfNotContains(string str, string sToAppend, string delimeter) { if (!str.Contains(sToAppend)) { str = AppendWithDelimeter(str, sToAppend, delimeter); } return str; } public static string AppendWithDelimeter(string str, string sToAppend, string delimeter) { if ((!str.EndsWith(delimeter) & !String.IsNullOrEmpty(str)) & !String.IsNullOrEmpty(sToAp... { str = str + delimeter; ......