posts - 5 , comments - 1 , trackbacks - 0

November 2016 Entries

Reposition DataTable Columns
After data bound to DataTable (say dtUser is DataTable name), if we would like to interchange FirstName (first column) and LastName (second column) columns position then we have to do like belowdtUser.Columns["FirstN... dtUser.Columns["LastName"].... //Initial ordinal position is ZERO Now LastName will be the first column and FirstName will be the second column in data table--Karthick Raju ......

Posted On Wednesday, November 9, 2016 4:54 AM | Comments (0) | Filed Under [ Asp.Net C# ]

Reset Identity column in SQL table
To reset Identity from 1Below would reset identity column of SQL table and start Identity column value from 1DBCC CHECKIDENT (TABLE_NAME, reseed, 0)To reset Identity from the specified value Say, If records are already deleted (from 31 to the end record ) and if user would like to create record from 31 then below will workDBCC CHECKIDENT (TABLE_NAME, reseed, 30)– Karthick Raju ......

Posted On Friday, November 4, 2016 6:44 AM | Comments (1) | Filed Under [ SQL SQL Server ]

How to execute Dynamic SQL query
Below SQL script would help to run simple dynamic queryDECLARE @SQLQuery NVARCHAR(500) — To see max length for NVARCHARSET @SQLQuery = N’SELECT * FROM TABLE_NAME’ — To understand why N’ in this lineEXEC(@SQLQuery)Ensure you execute dynamically framed query like EXEC (@SQLQuery) not like EXEC @SQLQuery. If you execute like later then you would get below errorMsg 2812, Level 16, State 62, Line 3Could not find stored procedure ‘SELECT * FROM TABLE_NAME’.-Karthick Raju ......

Posted On Friday, November 4, 2016 6:43 AM | Comments (0) | Filed Under [ SQL SQL Server Dynamic Query ]

ASP.Net Prevent navigation on Back Space button
Web sites will usually redirect user to previous page, if Back Space button is pressed. I have recently got the requirement to prevent user from navigating during this scenario.For this, we have to prevent back space button’s event fire on key down. But, if focus is on text box/text area then Back Space should work.Below code will work if you have this as a requirement:// Prevent the backspace key from navigating back.$(document).keydown(fu... (e) { var doPrevent; if (e.keyCode == 8) { var d = ......

Posted On Friday, November 4, 2016 6:38 AM | Comments (0) | Filed Under [ Asp.Net JavaScript ]

Sort listbox items using jQuery in ASP.Net
First of all, we have to refer jQuery on the page. Kindly down the latest jQuery from below urlhttps://plugins.jquery.c... is the function, will sort list box items in the ascending orderfunction SortListbyAscending(listname) { var $r = $(listname + ” option”); $r.sort(function (a, b) { return parseInt(a.value) == parseInt(b.value) ? 0 : parseInt(a.value) < parseInt(b.value) ? -1 : 1; }); $($r).remove();$(listname).... listbox as a parameter to run the above function. ......

Posted On Friday, November 4, 2016 6:32 AM | Comments (0) | Filed Under [ Asp.Net JavaScript jQuery ]

Powered by: