Posts

Showing posts from November, 2012

Number Allignment in gridview for dynamic data display

  protected void dgBatting1_RowDataBound(object sender, GridViewRowEventArgs e)         {             DataTable dt=(DataTable)((GridView)sender).DataSource;             if (e.Row.RowType == DataControlRowType.DataRow)             {                 for(int i=0; i < e.Row.Cells.Count; i++)                 {                     if (dt.Columns[i].DataType == typeof(System.Int32) || dt.Columns[i].DataType == typeof(System.Decimal))                     {                         e.Row.Cells[i].HorizontalAlign = HorizontalAlign.Right;                     }                 }                           }         }

Keyboard Shortcut Keys for Visual Studio

Ctrl-Del Delete next "word" Ctrl-Shift-S Saves all files and projects F7 Switches from the design view to the code view in the editor Shift-F7 Switches from the code view to the design view in the editor Shift-F8 or F8 Navigate to compile time errors Alt-Shift-A Add Existing Item(file) to selected project Ctrl-Shift-A Add New Item(file) to selected project F12 Moves the cursor to the selected method, variable, class definition. Ctrl-] Moves the cursor to the matching brace in the document. If the cursor is on an opening brace, this will move to the corresponding closing brace and vice versa Shift-Tab Moves current line or selected lines one tab stop to the left Ctrl-K, Ctrl-C Marks the current line or selected lines of code as a comment, using the correct comment syntax for the programming language Ctrl-K, Ctrl-U Rem

Find control in gridview_rowcommand event

 protected void dgAvailability_RowCommand(object sender, GridViewCommandEventArgs e)         {             try             {                 if (e.CommandName == "Save")                 {                     GridViewRow row = (GridViewRow)(((Button)e.CommandSource).NamingContainer);                     DropDownList ddl = (DropDownList)row.Cells[3].FindControl("ddlResponse");                     BFixturePlayer obj = new BFixturePlayer();                     obj.Key = int.Parse(dgAvailability.DataKeys[row.RowIndex].Value.ToString());                     obj.Response = int.Parse(ddl.SelectedValue);                     obj.SaveResponse();                     LoadAvailability();                 }                             }             catch (Exception exp)             {                 divError.InnerHtml = exp.Message;             }         }

Create Virtualdirectory in existing website in iis

  Create virtual directory in already existing website in iis 7.0 using asp.net,C# try     {         CreateVirtualDir("localhost", "websiteName" ,"MyVirtualDirectory123", @"E:\testclub");     }     catch (Exception ex)     {         lblMessage.Text = string.Concat("An error occurred: ", ex.Message);     }  private void CreateVirtualDir(string serverName, string website, string appName, string path)     {         DirectoryEntry IISSchema = new DirectoryEntry(string.Concat("IIS://", serverName, "/Schema/AppIsolated"));         bool canCreate = IISSchema.Properties["Syntax"].Value.ToString().ToUpper() != "BOOLEAN";         IISSchema.Dispose();         //get the identifier for the site we want         int identifier = 0;         DirectoryEntry root = new DirectoryEntry(string.Concat("IIS://", serverName, "/W3SVC"));         foreach (DirectoryEntry de in root.Children)         {