Search This Blog

Thursday, September 29, 2011

How to use GridViewDataRow with html contents.

If datasource(datatable) has html contents and bind this datasource to the gridview.
The GridView will show the data as it is in datatable.It means it will show the html content as it is.
For Example:
Your DataTable has html content "<Strong>Testing</Strong>" but gridview display same "<Strong>Testing</Strong>" instead of "Testing".

Solution:

Add the following code into gridView's Rowdatabound event.

protected void GridView_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
foreach (TableCell cell in e.Row.Cells)
{
cell.Text = Server.HtmlDecode(cell.Text);
}
}

Tuesday, September 27, 2011

How to swap column value of a sql table.

Create Table tmp (A varchar(10),B VARCHAR(10))


insert into tmp values('a','1')
insert into tmp values('b','2')
insert into tmp values('v','3')

Select * from tmp

output
A B
a 1
b 2
v 3

Update #tmp Set A=B, B=A

Select * from tmp
swapped output
A B
1 a
2 b
3 v

Sunday, September 25, 2011

Handler "PageHandlerFactory-Integrated" has a bad module "ManagedPipelineHandler" in its module list

This error comes when you are trying to access iis7.0 or upgraded and iis is not register for asp.net.
Solution:Register IIS with ASPNET4.0 as follows......

c:\windows\microsoft.net\framework\v4.0.30319>aspnet_regiis -i