more debugs

Showing posts with label MSSQL. Show all posts
Showing posts with label MSSQL. Show all posts

Sunday, November 27, 2011

Creating Fixed Headers in an ASP.Net GridView using JavaScript

In Reference to  article in CodeProject particular article Grid View With Fixed Header I am stating the problem first and stating the solution.

Problem : Whenever we use grid view along with a webform which include master page. I mean if we place gridview in the ContentPlaceHolder, then the ID of the Grid View is found to be changed
So when we try to pass the ID (GridView1 in above mentioned example) we ge some error due to not finding the id by javascript on runtime.





Solution :
Replace
  ClientScript.RegisterStartupScript(this.GetType(), "CreateGridHeader", "<script>CreateGridHeader('DataDiv', 'GridView1', 'HeaderDiv')</script>");
     
 with
     System.Web.UI.Control cd = Page.Master.FindControl("GridView1");
      if (cd != null)
        {
            ClientScript.RegisterStartupScript(this.GetType(), "CreateGridHeader", "<script>CreateGridHeader('DataDiv', 'GridView1', 'HeaderDiv')</script>");
        } 
  // name of the gridview changes on fly when using with master page
        ClientScript.RegisterStartupScript(this.GetType(), "CreateGridHeader", "<script>function PageLoad(){CreateGridHeader('DataDiv', 'ctl00_ContentPlaceHolder1_GridView1', 'HeaderDiv');}</script>");



and add following code to body tag of master page (.aspx)

<body onLoad="PageLoad()">


And get the grid view working as described in code project.



Thank you.

Follow Me 



  

Friday, November 25, 2011

SQL SERVER – 2008 – Configure Database Mail – Send Email From SQL Database

There are 3 basic steps that need to be carried out. 

1) Create Profile and Account.
2) Configure Email.
3) Send Email.

Step 1) Create Profile and Account:

You need to create a profile and account using the Configure Database  Mail Wizard which can be accessed from the Configure Database Mail context menu of the Database Mail node in Management Node. This wizard is used to manage accounts, profiles, and Database Mail global settings which are shown below:



eMail through MSSQL 2008 Mail service


Figure 1:- sendingMailstep-1


eMail through MSSQL 2008 mail service
Figure 2:- sendingmail-step2
MSSQL 2008 email service
Figure 3:- sendingmail-step3

Send Email through MSSQL 2008 mail service
sendingmail-step4
EMail through MSSQL 2008 mail service
Figure 5:- sendingmail-step5


EMail through MSSQL 2008 mail service
Figure 6:- sendingmail-step6




Step  2) Configure Email.

Upto now your account and profile are created successfully, we need to configure the Database Mail. To Configureit, we may need to enable the Database mail XPs parameter through the sp_configure store procedure, as shown here:

 sp_CONFIGURE 'show advanced',1
GO
RECONFIGURE
sp_CONFIGURE 'Database Mail XPs',1
GO

RECONFIGURE
GO

 Step  3) Send Email.

After  all configuration are done, we are now ready to send an email. To send mail, we need to execute a store procedure sp_send_dbmail and provide the required parameters as show below:

EMail through MSSQL 2008 mail service
sendingmail-step7