Monday, 13 May 2013

Get the Last Execution Date/time for a Stored Procedure

Get the Last Execution Date/time for a Stored Procedure

 
Select
b.name, s.last_execution_time from sys.dm_exec_procedure_stats s
INNER
JOIN sys.objects b
ON s.object_id = b.object_id
where s.type='P'
order by last_execution_time desc


Monday, 22 April 2013

Get the List of Tables and Column having the Identity Field or Column

To get the list of tables having identity columns, we can use the INFORMATION_SCHEMA view of the SQL Server. Below is the script:

selectCOLUMN_NAME, TABLE_NAME
from
INFORMATION_SCHEMA.COLUMNS
whereTABLE_SCHEMA = 'dbo'
andCOLUMNPROPERTY(object_id(TABLE_NAME), COLUMN_NAME, 'IsIdentity') = 1
order
by TABLE_NAME

 

Thursday, 27 December 2012

Use of Ajax HoverMenuExtender as Tooltip

How we can make custom tooltip using Ajax HoverMenuExtender ....


<ajaxControls:HoverMenuExtender ID="HoverMenuExtender1" runat="server" TargetControlID="ImgBtn1" PopupControlID="pnl_Hover_Details" PopupPosition="Right" OffsetX="0" OffsetY="0" PopDelay="0"> </ajaxControls:HoverMenuExtender>

<asp:Panel ID="pnl_Hover_Details" runat="server" Width="150px" Height="50px" BackColor="#CCFF99" BorderColor="#999999" BorderStyle="Solid" BorderWidth="1pt">
  <div style="width: 150px; height: 50px">
      Details are as follow...  </div>
</asp:Panel>

Update Progress Bar over the web page


Get the Progress Bar over the controls of the page,while the processing is going on....

 <asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="Updatepanel1">
<ProgressTemplate>
<div id="progressBackgroundFilter">
</div>
<div id="processMessage">
<img alt="Loading" src="../Images/processingbar.gif" />
</div>
</ProgressTemplate>
</asp:UpdateProgress>

Style Sheet:


#progressBackgroundFilter
{position: fixed;
top: 0px;
bottom: 0px;
left: 0px;
right: 0px;
overflow: hidden;
padding: 0;
margin: 0;
background-color: #000000;
filter: alpha(opacity=70);
opacity: 0.5;
z-index: 1000;
}
 #processMessage
{
position: fixed;
top: 48%;
left: 42%;
z-index: 1001;
background-color: #000;
filter: alpha(opacity=50);
opacity: 0.5;
color:#fff;
font-size: 14px;
font-weight:bold;
width: 0mm;
height: 0mm;
text-align:center;
}

Wednesday, 11 July 2012

Add Custom Gridview Header Dynamically in Asp.Net C#

Example ScreenShot:


In code-behind, on the 'OnRowCreated' event of gridview, write the follwing code:


 
protected void GdvAccountWise_RowCreated(object sender, GridViewRowEventArgs e)
{
try
{
if (e.Row.RowType == DataControlRowType.Header)
{
#region HeaderRow
GridViewRow HeaderRow = new GridViewRow(0, 0, DataControlRowType.Header, DataControlRowState.Insert);


TableCell HeaderCell = new TableCell();
HeaderCell.Text = "Account";
HeaderCell.ColumnSpan = 2;
HeaderRow.Cells.Add(HeaderCell);


HeaderCell = new TableCell();
HeaderCell.Text = "Date";
HeaderCell.ColumnSpan = 2;
HeaderRow.Cells.Add(HeaderCell);


HeaderCell = new TableCell();
HeaderCell.Text = "Utilization";
HeaderCell.ColumnSpan = 3;
HeaderRow.Cells.Add(HeaderCell);


Gridview1.Controls[0].Controls.AddAt(0, HeaderRow);


GridViewRow HeaderRow1 = new GridViewRow(1, 0, DataControlRowType.Header, DataControlRowState.Insert);


HeaderCell = new TableCell();
HeaderCell.Text = "AccountID";
HeaderRow1.Cells.Add(HeaderCell);


HeaderCell = new TableCell();
HeaderCell.Text = "AccountName";
HeaderRow1.Cells.Add(HeaderCell);
......................
......................
Gridview1.Controls[0].Controls.AddAt(1, HeaderRow1);


#endregion


}
}
catch (Exception ex)
{
  //catch exception code;
}
}


Hope this post will be helpful to you.
Do like and Comment if you like the post..!

Monday, 2 July 2012

Formatting Dates/Times in ASP.NET

Standard Date/Time Format Strings


Click On Image to Enlarge

Custom Date/Time Format Strings

Click On Image to Enlarge

My Date/Time Formatting Methods


Click On Image to Enlarge






Previous Date/Time Formatting Methods :
                 
DateTime.Now.AddDays(-1).ToString(
Output:
Sunday, July 08, 2012

"D");

How to show Gridview as a tooltip on mouseover of a cell of gridview in asp.net C# ?


We can achieve this using Ajax HoverMenuExtender & OnRowDataBound Event of Gridview


In  .aspx page:Use TemplateField in the Base Gridview as below:


<asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" EnableModelValidation="True"
                    OnRowDataBound="GridView2_RowDataBound">
                    <Columns>
                        <%--<asp:BoundField HeaderText="MenuId" DataField="MenuId" />--%>
                        <asp:BoundField HeaderText="MenuName" DataField="MenuName" />
                        <asp:BoundField HeaderText="MenuRefID" DataField="MenuRefID" />
                        <asp:BoundField HeaderText="MenuUrl" DataField="MenuUrl" />
                        <asp:TemplateField HeaderText="Menu ID">
                           <ItemTemplate>
                                <asp:LinkButton ID="LinkButton1" runat="server" Text='<%# Eval("MenuId") %>'>LinkButton</asp:LinkButton>
                                <asp:HoverMenuExtender ID="HoverMenuExtender1" runat="server" TargetControlID="LinkButton1"
                                    PopupControlID="Panel2" PopupPosition="Right" OffsetX="0" OffsetY="0" PopDelay="50">
                                </asp:HoverMenuExtender>
                                <asp:Panel ID="Panel2" runat="server">
                                    <asp:GridView ID="GridView3" runat="server">
                                    </asp:GridView>
                                </asp:Panel>
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Columns>
                </asp:GridView>


In Code-Behind:

protected void GridView2_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            DataRowView dr = (DataRowView)e.Row.DataItem;
            int menuId = Convert.ToInt32(dr["MenuId"]);
            //Session["menuid"] = menuId;
            //LinkButton lnkbtn = (LinkButton)e.Row.FindControl("LinkButton1");
            //Panel pnl = (Panel)e.Row.FindControl("Panel2");


            GridView secondGrid = (GridView)e.Row.FindControl("GridView3");
            DataTable dtForSecondGrid = new DataTable(); //here you populate this table with values by passing the key 'menuid'
            SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["con"].ToString());
            string str = "Select * from MenuDetails where MenuId="+menuId;
            SqlDataAdapter da = new SqlDataAdapter(str, con);
            da.Fill(dtForSecondGrid);
            secondGrid.DataSource = dtForSecondGrid;
            secondGrid.DataBind();
        }
    }