web 2.0

Delete button with Javascript confirm in Datagrid

It is often a good practice to show a confirmation alert to the user when they select to delete any record. So for that, here is the quick code consider the following grid view. 
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"BackColor="White" BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px"CellPadding="3" DataKeyNames="CategoryID" DataSourceID="SqlDataSource1"ForeColor="Black" GridLines="Vertical" Width="100%" onrowcommand="GridView1_RowCommand"><Columns><asp:BoundField DataField="CategoryID" HeaderText="CategoryID"InsertVisible="False" ReadOnly="True" SortExpression="CategoryID" /><asp:BoundField DataField="CategoryName" HeaderText="CategoryName" SortExpression="CategoryName" /> <asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" /><asp:TemplateField><ItemTemplate><asp:LinkButton ID="lbDelet" CommandName="del" runat="server" Text="Delete" OnClientClick="javascript:return confirm('Are you sure you want to delete ?');"></asp:LinkButton></ItemTemplate></asp:TemplateField></Columns><FooterStyle BackColor="#CCCCCC" /><PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" /><SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" /><HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" /><AlternatingRowStyle BackColor="#CCCCCC" /></asp:GridView 
Notice the last column which is template column and having a link button (ID = lbDelet). onClientClick is doing the main stuff.That's it cheers

Could not load file or assembly Microsoft.SqlServer.Management.Sdk.Sfc

Another sick error of the day, When you try to create connection string from SQLDatasource or even want to bind existing connection string. You might see a Message box saying
Could not load file or assembly 'Microsoft.SqlServer.Management.Sdk.Sfc, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The system cannot find the file specified.
This error comes when you are trying to access SQL 2005 stuff from Visual Studio 2008.  So go to the link and download the following stuff
  • Microsoft SQL Server System CLR Types
  • Microsoft SQL Server 2008 Management Objects
  • Microsoft SQL Server 2008 Native Client