Friday, March 4, 2016

How to submit / save changes in LinqPad

void Main()
{
    var students = Student.Select(st => st);
    foreach (var student in students)
    {
        student.FatherName = "Father";
    }
    SubmitChanges();
}

Monday, February 29, 2016

How to change a value of a DataItem in a GridViews RowDataBound Event

if (e.Row.RowType == DataControlRowType.DataRow)
{
 DataRow row = ((DataRowView)e.Row.DataItem).Row;
 for (int i = 0; i < row.ItemArray.Length; i++)
 {
  var obj = row.ItemArray[i];
  if (obj.GetType().Name == "DateTime")
  {
   e.Row.Cells[i + 1].Text = ((DateTime)obj).ToShortDateString();
  }
  else if (obj.GetType().Name == "Boolean")
  {
   e.Row.Cells[i + 1].Text = ((Boolean)obj).ToYesNo();
  }
 }
}

jQuery: get the file name selected from

$('input[type=file]')[0].files[0].name;

$("input[type=file]")[0].files[0].type;

$("input[type=file]")[0].files[0].size;

Wednesday, February 24, 2016

How do you check if a certain index exists in a sql server table?

IF EXISTS(SELECT * FROM sys.indexes WHERE name='[IndexName]' AND object_id = OBJECT_ID('[Schema].[Table]'))
BEGIN
    --statements
END

Tuesday, February 23, 2016