Friday, November 29, 2019

Getting DataKeyNames for row on button click

protected void viewHoursButton_OnClick(object sender, EventArgs e)
{
    Button btn = sender as Button;
    GridViewRow row = btn.NamingContainer as GridViewRow;
    string pk = storyGridView.DataKeys[row.RowIndex].Values[0].ToString();
    System.Diagnostics.Debug.WriteLine(pk);
}

GridView button click event (sender)



 TextBox txt = (TextBox)sender;

 GridViewRow gvRow = (GridViewRow)txt.Parent.Parent;

 DropDownList ddl=(DropDownList)gvRow.FindControl("ddl");

Select the first day of a month in SQL

Month First Day


SELECT DATEADD(month, DATEDIFF(month, 0, @mydate), 0) AS StartOfMonth


SELECT
   DATEADD(yy, DATEDIFF(yy, 0, GETDATE()), 0) AS StartOfYear,
   DATEADD(yy, DATEDIFF(yy, 0, GETDATE()) + 1, -1) AS LastDayOfYear,
   DATEADD(yy, DATEDIFF(yy, 0, GETDATE()) + 1, 0) AS FirstOfNextYear,
   DATEADD(ms, -3, DATEADD(yy, DATEDIFF(yy, 0, GETDATE()) + 1, 0)) AS LastTimeOfYear

Thursday, November 28, 2019

How to stop browser closing automatically when you stop debugging on VS 2017

Disabling the following checkboxes will allow you to keep the browser open (doesn't close after stop debugging) and opens another tab (instead of another window)


Tools > Options > Debugging > General
  • Disable "Enable JavaScript debugging for ASP.NET (Chrome, Edge and IE)".
Tools > Options > Projects and Solutions > Web Projects
  • (Visual Studio 2017) Disable "Stop debugger when browser window is closed".
  • (Visual Studio 2019) Disable "Stop debugger when browser window is closed, close browser when debugging stops".


Sunday, November 24, 2019

windows port kill command


Port Kill Command
C:\windows\system32>netstat -a -n –o
taskkill -f /pid 19796


base 64 convert to image

public Image LoadImage() {     //data:image/gif;base64,     //this image is a single pixel (black)     byte[] bytes = Convert.FromBase6...