Thursday, September 23, 2010

Comma Seperated Values from Tables in SQL

Hi Everyone,
This blog helps you to display the table column value to comma seperated values.
First we have to select the table and before the column name, kindly add a ','.
Then keep the select as inner query and use substring in the select query.
This substring will need 3 parameters - Expression,Start-Position,Length.
Give this as it is! the value 2 has given as start position to remove the first comma present in the final list.
 
 
SELECT SUBSTRING(
(
SELECT ',' +
s.Name
FROM
HumanResources.Shift s
ORDER BY
s.Name
FOR XML PATH('')),2,200000) AS
CSV
GO


By this way, We can make the table to csv..
 
Regards 
M.K.Kannan..

Wednesday, September 22, 2010

Type Name for Object Datasource in GridView in ASP.NET

Hi,
The Object Datasource control used for the gridview needs a TypeName for the control to get the value from the backend.
When we have a seperate project for ASPX and ASPX.CS files, The type name can be given as the Project name of the ASPX.CS Class library.
But when we create a website or webapplication, The ASPX and ASPX.CS will be in the same project.
That time, the TYPENAME  will not accept the current project name.
For that we can assign the TypeName value in the codebehind as follows
 
-----------------------------------------------------------------------------------------------------------------
 
string typeName = this.GetType().AssemblyQualifiedName;
objectDSAccountList.TypeName = typeName;
-----------------------------------------------------------------------------------------------------------------
 
By adding the above code in the code behind.
We can add an object datasource to a gridview or a repeater to use the paging concept for getting data.
By using this Object Datasource. We can take only a limited amount of records to be taken from the database w.r.t page size.
 
To use Object Datasource, See my blog posted on June 2009 for further reference.
 
Thank YOu
Yours
Kannan.K.Mangudi

HTML/JAVASCRIPT BLOG

You can find the help for html and javascript codes

Any Doubts Contact my Mail-ID:
kannan.mkv@gmail.com