8 May 2014

DateTime Format in gridview column



    <asp:GridView ID="gv_1" runat="server" AutoGenerateColumns="false">
        <Columns>
            <asp:TemplateField HeaderText="Color">
                <ItemTemplate>
                    <asp:Label ID="lbl_date" runat="server" Text='<%# Eval("Your_Date_Column_name", "{0:MMMM d, yyyy}") %>' />
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
    </asp:GridView>

5 May 2014

Dropdown events in javascript



  1.  onChange – Occurs after a value is selected from the dropdown.
  2.  onFocus – Occurs after the dropdown gains focus. It triggers the JavaScript event before the dropdown is opened.
  3. onBlur – Occurs after a value is selected from the dropdown and the focus is removed from it.
  4. onKeyDown – Occurs after a keyboard key is released when the dropdown is opened or when the dropdown has the focus.
  5. onKeyDown – Occurs after a keyboard key is pressed when the dropdown is opened or when the dropdown has the focus.
  6. onClick – Occurs after a dropdown is clicked.
  7. onMouseOver – Occurs after the dropdown is hovered with the mouse cursor.
  8. onMouseDown – Occurs after the dropdown is clicked. Works similar to the onClick event but it triggers the JavaScript event before the dropdown values are expanded.
  9.  onMouseUp – Occurs after the dropdown is clicked and the click button is released.

Textbox events in javascript

  1. OnBlur – occurs when TextBox control loses focus;
  2. OnChange – occurs when text in the TextBox control is changed;
  3. OnFocus – occurs when TextBox control gain focus;
  4. OnKeyDown – occurs when you press a keyboard key in the TextBox control;
  5. OnKeyPressed – occurs when you press or hold down a keyboard key in the TextBox control;
  6. OnKeyUp – occurs when you release the keyboard key pressed before in the TextBox control;
  7. OnClick – occurs when you click on the TextBox control;

30 April 2014

How to Sort a DataTable given column and direction in c#.net

public static DataTable resort(DataTable dt_input, string colName, string direction)  //direction means "ASC" or "DESC"
        {
            DataTable dt_output = null;
            dt_input.DefaultView.Sort = colName + " " + direction;
            dt_output = dt_input.DefaultView.ToTable();
            return dt_output;
        }