Geeks With Blogs
AzamSharp Some day I will know everything. I hope that day never comes. December 2005 Entries
Generate Parameters Collection Using T-SQL
How many times have you written the following lines? myCommand.Parameters.AddWit... ..... .... .... and so on. If you are attaching only 3-4 parameters then its okay but what about attaching 10-15 parameters. That will be lot of typing and wasting some precious time. I made a small T-SQL that will generate the parameter collection for you provided the table name. USE Northwind-- declare the variables DECLARE @column_name varchar(20) DECLARE @ordinal_position int DECLARE @counter ......

Posted On Saturday, December 31, 2005 10:18 PM

Highlights from the year 2005
Finally, YEAR 2005 is closed to end. A fresh start into the next year with new dreams and tasks. Year 2005 was very special year for me. Here are some highlights of what happened: 1) Went to California for the first time in January 2005 to meet the girl of my dreams. 2) Turned 24 years old in Febuary (This happens every year) 3) Got married in August 2005 (Although my wife is still in California doing her studies) 4) Got cell phone (I know this is pretty lame) 5) Passed Microsoft Certification Exam ......

Posted On Saturday, December 31, 2005 2:03 PM

Place an "X" where a GridView Cell is Blank
If you are dealing with some data and you know that the GridView cell can be blank and you want to display some text instead of the blank cell then you can use the following code. <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" OnRowDataBound="GridView1_R... <Columns> <asp:BoundField DataField="CustomerID" HeaderText="CustomerID" /> <asp:BoundField DataField="Name" HeaderText="Name" /> <asp:TemplateField HeaderText="Test Column"> <ItemTemplate> ......

Posted On Friday, December 30, 2005 11:47 PM

Authenticating Users Using ASP.NET 2.0 Login Control
I just wrote a small article which demonstrates how you can authenticate a user against different sources. These sources include MemberShip details tables, Custom Database and XML file. Check out the article at the following link: Authenticating Users Using Login Control powered by IMHO 1.3 ......

Posted On Friday, December 30, 2005 4:04 PM

Using INSERT to remove duplicate rows
After good 1 day in San Antonio now once again I am in the back seat of the car and going to Austin. Anyway, I am reading this great book by Ken Henderson about T-SQL programing and in this book he has mentioned a neat trick to remove duplicates using the INSERT statement and index. CREATE TABLE #test1 (c1 varchar(20), c2 int, notes text) INSERT INTO #test1 VALUES('AzamSharp',1,'Somet... special for everyone') INSERT INTO #test1 VALUES('AzamSharp',1,'Not so special after all') INSERT INTO #test1 ......

Posted On Monday, December 26, 2005 4:07 PM

TimeStamp datatype in SQL SERVER 2000
Well, believe me or not but right now I am in the back seat of the car and going to San Antonio. Anyway, good thing I charged my laptop so I can play around with SQL SERVER 2000. When working with timestamp datatype and you want to get the last timestamp value inserted you can simply use the @@DBTS. CREATE TABLE #testts ( k1 int identity(1,1) PRIMARY KEY, updatelog timestamp) INSERT INTO #testts DEFAULT VALUES INSERT INTO #testts DEFAULT VALUES INSERT INTO #testts DEFAULT VALUES INSERT INTO #testts ......

Posted On Sunday, December 25, 2005 3:13 PM

SqlDataSource smart tag not so smart after all !
I decided to use SqlDataSource by simply dragging and dropping it on the form. Then I clicked on the smart tag to configure my connection string and I come up with this error. any ideas anyone or is this another of Visual Studio.NET 2005 BUGS? powered by IMHO 1.3 ......

Posted On Saturday, December 24, 2005 11:17 PM

Solving the Location path problem in Visual Studio.NET 2005
Here is a work around to the problem I discussed in my previous post: Just make a separate system.web element: <configuration> <appSettings/> <connectionStrings/> <location path="Admin"> <system.web> <authorization> <deny users="?"/> </authorization> </system.web> </location> <system.web> <compilation debug="true" /> <authentication mode="Forms"> <forms loginUrl ="Login.aspx" timeout ="10"> </forms> </authentication> ......

Posted On Saturday, December 24, 2005 3:06 PM

<location path = [FolderName] /> is giving problems in VS.NET 2005. Is this another BUG!!!
Talk about BUGS! not the movie but bugs in Visual Studio.NET 2005. I was trying to implement simple security in Visual Studio.NET 2005 by using folder security. So, I created a folder name "Admin" and make these settings in my web.config file. <location path="Admin"> <system.web> <!-- Set compilation debug="true" to insert debugging symbols into the compiled page. Because this affects performance, set this value to true only during development. --> <compilation debug="true"/> ......

Posted On Saturday, December 24, 2005 1:52 PM

Hyperlinks inside the DataList, Datagrid or GridView control
Sometimes we need to get some id from the database table and use that id to generate the link. Something like this: SomePage.aspx?id=34 You can easily do this by using the following code: <ItemTemplate><asp... ID="myHyperlink" Text='<%# Eval("CategoryName") %>' NavigateUrl='<%# FormatUrl( (int) Eval("CategoryID")) %>' runat="server">[myHyperl... </ItemTemplate>And here is the FormatUrl method: protected string FormatUrl(int categoryID) { ......

Posted On Thursday, December 22, 2005 5:52 PM

RegisterForEventValidation can only be called during Render();
This error comes when you are exporting the GridView control in the Visual Studio.NET 2005 BETA Versions. I am using the released version so I never got this error. Anyway, you can solve this error but the trick is very dirty. You have to turn the eventValidation off in order for this to work. You can do this in the web.config file but in this case the eventValidation will be turned off for all the pages. <pages enableEventValidation ="false" ></pages> or you can do this in the Page directive ......

Posted On Wednesday, December 21, 2005 11:39 PM

Export GridView to Excel Complete Code!
Here is the complete code to Export GridView to Excel: using System;using System.Data;using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;u... System.Web.UI.WebControls.W... System.Web.UI.HtmlControls;... System.Data.SqlClient; public partial class ExportGridView : System.Web.UI.Page{ protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { GridView1.DataSource = BindData(); ......

Posted On Wednesday, December 21, 2005 11:06 PM

Hey Microsoft! Can you make this any harder?
I was trying to send email using ASP.NET 2.0 using the following code: MailMessage message = new MailMessage(); message.From = new MailAddress("iamazam@hotmai... message.To.Add(new MailAddress("azamsharp@gmai... message.Subject = "This is my subject"; message.Body = "This is the content"; SmtpClient client = new SmtpClient(); client.Host = "localhost"; client.Send(message); but I keep getting the error: Failure sending mail.Unable to connect to the remote server The bad thing is that there ......

Posted On Wednesday, December 21, 2005 7:53 PM

Building a small TODO Task Application in ASP.NET 2.0
Someone once said that the best way to learn the new technology is to build several application that are implemented in it. I will be starting to make a small application about How to create a simple TODO Task Application. This application will be implemented in ASP.NET 2.0 using C# and SQL SERVER 2000. I will cover the whole process of this application in the form of articles on my website www.gridviewguy.com. This will be a small series of articles. I hope you like this small series of articles. ......

Posted On Wednesday, December 21, 2005 11:05 AM

DataSet new features in ASP.NET 2.0
Just came back to Houston yesterday after my small 3 day vacation to California. Anyway, check out my article about new features in DataSet and DataTable in ASP.NET 2.0. DataSet New Features in ASP.NET 2.0 powered by IMHO ......

Posted On Tuesday, December 20, 2005 3:38 PM

Going to California for couple of days!
After a long long long semester and graduation I decided to take a small vacation. I am going to California tomorrow (12-16-2005) for couple of days (3 days). This will be kinda like small graduation party which I desperatly needed. I might not be able to check my emails and stuff but once I come back I will answer all the emails. Take care everyone and HAPPY HOLIDAYS! powered by IMHO ......

Posted On Thursday, December 15, 2005 6:00 PM

NUnit, a huge mess when being used for Visual Studio.NET 2005
Well, I am quite frustated :(. I spent last 2-3 hours trying to figure out how to use the NUnitASP with Visual Studio.NET 2005. I pretty much tried everything I could find on google. So, I downloaded NUnitASP and also NUnit 2.2.3. After that I made a class library project and added the references to the nunit.framework.dll and nunitasp.dll. I ran the application and the error: BadImageFormatException was thrown right on my face. After some search I figure out that I need to modify some settings in ......

Posted On Wednesday, December 14, 2005 2:57 PM

Adding NameSpace in Visual Studio.NET 2005
I simply love this new feature! Consider a situation where you create an object of a class whose namespace is not yet added. The only way you can use it is by adding its namespace at the top. Visual Studio.NET allows you to add the namespace automatically. Check out the screen shot below to see what I mean :). pretty cool right! powered by IMHO ......

Posted On Wednesday, December 14, 2005 10:40 AM

DataTableReader in Asp.net 2.0
DataTableReader is pretty much like SqlDataReader but it lets you iterate through the DataTables and DataSets. Here is a simple code that demonstrate it. The important thing to note is that even if you add the row to the DataTable at the time of iteration the DataTableReader will pick that up. private void IteratingDataTable() { DataTable customerTable = GetDataTable(); DataTableReader dtReader = new DataTableReader(customerTab... while (dtReader.Read()) { Response.Write( (string) dtReader["Name"]); ......

Posted On Tuesday, December 13, 2005 10:20 PM

Using GROUP BY WITH Text DataType
If you try to use the GROUP BY clause with the Text datatype it will throw an error telling you that you cannot use GROUP BY with Text DataType. There is a easy work around to this simply convert the Text Datatype to a varchar and the GROUP BY will work. Here is a simple example: -- Get all the post not depending if it has the thread or not SELECT p.PostID, p.Url, p.Title,COUNT(t.ThreadID),p... FROM Posts pLEFT OUTER JOIN Threads t ON p.PostID ......

Posted On Monday, December 12, 2005 12:09 AM

Refactor the SQL Queries!
Well, Some time ago I wrote this nasty query to select the posts which are of the present month. CREATE PROCEDURE usp_GetCurrentPosts AS DECLARE @CurrentYear int DECLARE @CurrentMonth int SET @CurrentYear = YEAR(GETDATE()) SET @CurrentMonth = MONTH(GETDATE()) SELECT PostID, Title, Url, Description, DateCreated FROM PostsWHERE @CurrentYear = YEAR(DateCreated) AND @CurrentMonth = MONTH(DateCreated) ANDActive = 1GO Today I refactored it out to this: -- Get all the post not depending if it has the thread ......

Posted On Sunday, December 11, 2005 11:50 PM

JavaScript Debugger Awesome!
Sahil Malik discovered an awesome JavaScript Debugger. Check it out here . powered by IMHO ......

Posted On Sunday, December 11, 2005 9:55 PM

Auto Suggest Functionality using AJAX.NET Library
Couple of months ago I wrote an article on how to implement Google Suggest Functionality using AJAX.NET Library. I managed to improved it little bit more and now you can use the cursor keys to select the items from the listed suggestions. I will be writing an article about this shortly and will upload it to my website www.gridviewguy.com. One thing that I was not able to figure out was how to change the row colors of the div rows since I am using plain DIV with no element inside it. Anyway, if any ......

Posted On Saturday, December 10, 2005 5:09 PM

Screen Scrape Button Control
I created a very simple Screen Scrape Button Control which you can use to export the html of a particular page to a text file. I have also made a property Expression which you can use to set any regular expression and hence narrow your exportation task. This control will be available for free. Please check back the website www.gridviewguy.com in couple of days where you will find the link to download the control. Here is a the part of the code to dynamically load the control: ScreenScrapButton sButton ......

Posted On Tuesday, December 6, 2005 8:24 PM

Sold my first Export Button Control
Today I sold my first Export Button Control to a gentleman :). I am quite happy about it. If you are not familier what I am talking about then here is a brief introduction about the Export Button. Export Button: Export Button will allow you to export your DataGrid control to Excel, Text, XML or Word format file. All you need to do is to provide the ControlID to the Export Button and thats it. You can view the live demo of Export Button at Export Button Live Demo. I hope you like it :) powered by ......

Posted On Tuesday, December 6, 2005 1:59 PM

Few more days and then it will all over ...............
Just a few more days and I am done with my University. I am soo glad that I am graduating it has been long 3.5 years. My exams will end on 6th of December but after that I have an assignment due on 12th of december and then I will be free. I already made plans, I will be going to California from 16th to 19th to meet my beautiful wife :). After that I will come back and get back to work. I have already stacked up some books that I will be reading during the course of next year. powered by IMHO ......

Posted On Saturday, December 3, 2005 9:04 PM

Gmail atom feed is sweet!
Gmail atom feed allows you to display your unread email messages using any rss reader control. Its pretty sweet! Check out the link below to read your unread email. https://mail.google.com/mai... powered by IMHO ......

Posted On Friday, December 2, 2005 10:02 PM

Copyright © Mohammad Azam | Powered by: GeeksWithBlogs.net