Some day I will know everything. I hope that day never comes.
You can also sort DataBound columns of the GridView. The one thing that you need to do is to make the header columns as the links and write the client side scripts which will handle the client postbacks. Check out the code below. protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.Header) { TableCellCollection cells = e.Row.Cells; foreach (TableCell cell in cells) { cell.Text = Server.HtmlDecode(GenerateS... (cell.Text,GridView1)); ......
We all know that GridView columns can be sorted automatically when SQLDataSource is being used. But what if you are not using SqlDataSource to populate the GridView. Sorting the GridView manually is pretty straight forward task take a look at the code below. private const string ASCENDING = " ASC"; private const string DESCENDING = " DESC"; public SortDirection GridViewSortDirection { get { if (ViewState["sortDirection"] == null) ViewState["sortDirection"] = SortDirection.Ascending; return (SortDirection) ......
Talk about waste of time! I spend hours and hours trying to figure out that how to get the PopUpControlExtender work with a simple TextBox control and the Calendar control. The control works but does a postback so I placed it inside the UpdatePanel control but then it was throwing exceptions about the Duplicate id's. Anyway, the code below works well but does a postback to the server. <atlas:ScriptManager ID="sm" runat="server" EnablePartialRendering="true" /> <asp:Panel ID="up" runat="server"> ......
Sometimes you need to fire an event using the body onload just like shown below: <body onload="alert('Hello World')"> Some data </body> Now, if you are using the Master Page and writing the above piece of code in the master page then it will be fired for every page that inherits from the master page. But, you really need this to be fired only for a specific page. Here is a simple solution for this problem. In the master page make the body a control by giving the runat="server" attribute ......
GridViewGuy is always open for new articles. If you have written an interesting article that you think will benefit the developer's community than we would like to hear from you. This is also a great way to market yourself in the Information Technology world. Submission Guideline: Submitting an article is very simple. Simply email us your article in html or plain text format in a zip file. If you have any images or project files than include them in a zip folder. We strongly recommend that you also ......
Sometimes, we need to leave the AutoGenerateColumns = true since, we don't know how many columns will be returned from the Database. Another technique is to use ITemplate interface and make your custom Template Columns during runtime. All the columns that are generated automatically are BoundColumns. Sometimes you want to display the column as a link which will open a new window. In the code below I have added the required HTML to the rows of the DataTable and later linked the bound the table to ......
DataTable has a Select method which can help you limit the number of rows being selected using a criteria. But DataTable does not contain any method which can remove the duplicate rows. First, if you have duplicates rows then I suggest using the DISTINCT keyword of the SQL SERVER. But sometimes, your whole row is not a duplicate but some of the cells are repeating. Anyway, here is a simple method that can remove the duplicate rows from the DataTable. In the example below the UserID is the primary ......
Most probably you guys already know this but GridView control has TemplateField and not TemplateColumn. So, if you are thinking of creating GridView columns dynamically then make sure that you make TemplateField. powered by IMHO 1.3 ......
I know that I am missing something small but not really sure what it is. I just added the configuration in the web.config file to upgrade my project to ATLAS. Most of the controls that I have tried are working with the exception of the AutoCompleteExtender control. I even tried debugging the application but it never reaches the web services method. <form id="form1" runat="server"> <atlas:ScriptManager ID="sm" EnablePartialRendering="true" runat="server" /> <div> <asp:TextBox ......
You can use the ATLAS ConfirmButton to make the confirmation on more then a single button. For this purpose you don't need to have multiple instances of the ConfirmButton. Check out the code below which assigns the confirmation message to two buttons. ConfirmButtonExtender1.Targ... AtlasControlToolkit.Confirm... ConfirmButtonExtender1.Targ... (new AtlasControlToolkit.Confirm... ConfirmButtonExtender1.Targ... .ConfirmText ......
CascadingDropDown is simply great, it allows you to create the dependent DropDownLists with no postback (NO POSTBACK is the prime purpose of the ATLAS framework). You can configure your CascadingDropDown to be populated from the database table rather then the XML file. Here is the HTML part of the code: <atlas:ScriptManager ID="MyScriptManager" runat="server"></atla... Category: <asp:DropDownList ID="ddlCategory" runat="server"></asp:... <br /> ......
ATLAS ConfirmButton control comes with the ATLAS Control Toolkit. The purpose of the ConfirmButton is to simply give the user a confirmation message with choices "OK" and "Cancel". Now, if you press "OK" a postback will happen which kinda breaks the ATLAS rules of NO POSTBACK. On the other hand you can put the the ConfirmButton inside the UpdatePanel and it will be rendered without any POSTBACK. powered by IMHO 1.3 ......
I was using the UpdatePanel and was noticing some strange behavior. After some debugging I found some cool stuff about the UpdatePanel. The first thing that you need to know is that the UpdatePanel is rendered as a DIV element. I guess that was pretty obvious. The next thing is if you put a Button inside the UpdatePanel then the Button will refresh all the UpdatePanels. Check out the code below: <atlas:UpdatePanel Mode="Always" RenderMode="Block" ID="up1" runat="server"> <ContentTemplate> ......
If you are wondering that where the hell was AzamSharp AKA GridViewGuy then well, I have a good reason for it. I went to Seattle for an Interview with Microsoft. My interview was scheduled at 8:30 AM on Tuesday (03-21-2006) and due to flight delay I reached Redmond, Seattle at 2:00 AM. So, I guess you get the idea what shape I was in. Anyway, no one wants to hear my condition during the interview but you want to know about the Interview. So, here are the details. I was being intervied by two teams. ......
Although I have written an article on "Export GridView to Excel" I recieve many emails everyday asking the same question repeatedly. So, I decided to make a video tutorial in which I will implement the exportation task from start. You can watch the video at the following link. [Play the video] powered by IMHO 1.3 ......
This question was asked many times on www.asp.net forums so I decided to take a look at it. The question is that how we can get the value from the Profile object when using the Profile object inside the class library. I am assuming that your project contains the object of type User. The class User is created inside the ClassLibrary project which is part of the same solution as the Web Application Project. Here is the class User defined in the ClassLibrary Project. [Serializable] public class User ......
I am sure that you have experienced a BUG "Directory Name is invalid". This bug come into play when you have multiple instances of Visual Studio.NET 2005 open and you try to change the name of a server control. The workaround right now is to switch to the HTML view and change the name manually. powered by IMHO 1.3 ......
First of all you should not refer from the Class Library Project to the Web Application Project actually it works the opposite way. It is always a good practice to put all your business logic code in a separate project called Class Library Project. This way it will be much easier to port the library to different venders. If you are putting all your business logic classes inside the App_Code folder of the Web Application then you have to transfer the whole application to the vender when you only needed ......
Some time back I uploaded a video tutorial which demonstrated that how you can select multiple checkboxes inside the GridView control. I got lot of feedback from that video which encouraged me to make another video. This video will be about changing the row color of the GridView control when you put your mouse cursor over it. I was working on this video yesterday and I will complete it today and try to upload today in the evening. The video although, pretty simple but came up 20 minutes of running ......
I just blogged about on how you can change the GridViewRow color by simply moving your mouse pointer on it. Now you can also do an onlclick event on the GridViewRow which will highlight that particular row. The important thing to note is that when you click again on the highlighted row then it should come back to its orginal state. The code below uses the "hidden" field to solve this problem. Take a look at the code below: protected void MyGridView_RowCreated(object sender, GridViewRowEventArgs e) ......
Few months back I blogged about changing the Back Color of the row contained in the GridView control when you put your mouse cursor over it. In this blog entry I am doing the same thing more efficiently. Check out the code below: protected void MyGridView_RowCreated(object sender, GridViewRowEventArgs e) { string onmouseoverStyle = "this.style.backgroundColor... string onmouseoutStyle = "this.style.backgroundColor... string rowBackColor = String.Empty; if (e.Row.RowType == DataControlRowType.DataRow) ......
I just noticed that the Auto-Format feature of the Menu Control is not working when the project in Visual Studio.NET 2003 is exported to Visual Studio.NET 2005. What I did is added a simple master page and in the left column of my master page I added a simple Menu control. I used Auto-Format to assign some colors to the Menu Control. After that I simply used that master page in my other web pages. But the Menu renders without any color (I mean plain without any styles). Although I can see the style ......
Today, for the first time I decided to play a little bit around with Web Parts. Web Parts are ideal if you are making a "Portal Application" since it allows you to personalize parts of the web page. The basic controls which make up the Web Parts consists of WebPartManager, WebPartZone, Catalog Zone and Declarative Catalog. Apart from these controls Web Parts also contains tons of other controls. The good thing about Web Parts is that you can add any Web Server Control, User Control, Custom Control ......
I have decided that I will write GridViewGuy in ASP.NET 2.0. Although this whole process will take quite a while since I am too busy with my full time job and writing articles but I think it will be a good assignment. I already downloaded the Web Application Projects and migrated the existing Visual Studio.NET 2003 application to Visual Studio.NET 2005. The new GridViewGuy will take advantage of the Web Parts feature. The Atlas project is also released hence I will see if I can implement Atlas in ......
Hi, I just downloaded the migration tool so I can migrate my 2003 application to 2005. Now the migration wizard did all the migration but now when I try to run the application it throws me the exception saying: An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection ......
I am trying to use the UpdateProgress control which ships with ATLAS and was getting the error "Constructor is null or not an object". So, I thought maybe my ScriptManager controls needs the EnablePartialRendering attribute which I inclucded it. But even then the UpdateProgress control does not do anything. I am sure I am missing out something but what?? Here is my code: <form id="form1" runat="server"> <atlas:ScriptManager EnablePartialRendering="true" ID="ScriptManager1" runat="server" ......
Few days ago I downloaded Atlas Project and played around with it. I think its pretty neat although I have just touched the tip of the iceberg. I remember that some time back I wrote an article about Auto Suggest Using AJAX.NET Library. Now, with Atlas unleashed you can use its power to build the suggest functionality in minutes. I have already written an article about it which you can view at ATLAS AUTO-SUGGEST TEXTBOX. I hope you like it. powered by IMHO 1.3 ......
You might have already played around with the ObjectDataSource control and found out that you can send individual values to the class methods. You can also send the object itself to the class method. Take a look at the code below which sends the object filled with data being updated to the class method. User.cs: using System;using System.Data;using System.Configuration;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;u... System.Web.UI.WebControls.W... ......
I love ASP.NET 2.0 but what I hate is that when we publish the application it produces million of files (One for each webpage). It create a compiled version of the page and puts it in the bin directory. Now, the problem comes when you have an aspx page on the production and you simply want to change text in the aspx page. In VS.NET 2003 you could simply open the aspx file and change the text in the html view. But if you want to do the same for VS.NET 2005 then you need to compile and publish the ......
Last week when the product I was working on was supposed to go live and we faced a strange MS SQL error. It was called the SQLDumpException. Our team looked into it for several hours and later found out that it is a BUG in SQL SERVER 2000 Service Pack 3. So, finally this was fixed by simply installing the SQL SERVER 2000 Service Pack 4 and the product went live as planned. If you are facing the same problem simply download the install the SQL SERVER Service Pack 4 which will solve this problem. powered ......
Atlas is pretty cool since it allows you to make client side calls and hence saves the postback. Although the postback is still called but on the client side. Your Atlas client side calls can fail if you do a Response.Write when the postback is true. So, don't do the Response.Write. Check out the code below: protected void Page_Load(object sender, EventArgs e) { if (Page.IsPostBack == true) { Response.Write("This response will kill the page."); } } powered by IMHO 1.3 ......