Gautam Buddha Temple Varanasi,Varanasi - Buddhist Pilgrimage

Tuesday, March 30, 2010

Validate GridView textbox in clientside using javascript

 Find Gridview TextBox in client side using javascript  
 Here this article show show how we can find gridview textbox which is inside Template Field and validate the entry while
editing the record.  
 function ValidateGridEditMode()  
 {  
      var n = document.getElementById('ctl00_ContentPlaceHolder1_tbcLocation_tpnlCountry_gvEmp').rows.length;  
      var i;  
      for(i=2; i <=n; i++)  
      {   
           if(i<10)  
           {  
                txtEmpName=document.getElementById('ctl00_ContentPlaceHolder1_tbcLocation_tpnlCountry_gvEmp_ctl0'+i+'_txtEmpName');   
           }  
           else  
           {  
                txtEmpName=document.getElementById('ctl00_ContentPlaceHolder1_tbcLocation_tpnlCountry_gvEmp_ctl'+i+'_txtEmpName');   
           }  
           if(txtEmpName !=null)  
           {  
                if(txtEmpName.value == "")  
                {  
                     alert("Enter Emp Name...!");   
                     txtEmpName.focus();   
                     return false;  
                }   
           }   
      }  
      return true;  
 }  

Saturday, March 27, 2010

Single Stored Procedure for Insert and update record

It good idea to use a single stored proceude instead of write two stored procedure for insert and update.So i am here explainig how to do this.

here we can check if EnquiryId ==0 then insert otherwise update.

Create PROCEDURE [dbo].[uspEnquiry_AddEdit]
(
@EnquiryId bigint
, @EnquiryNo varchar(20) output
, @ClientId bigint
, @ContactPerson varchar(50)
, @Desig varchar(50)
, @Mobile varchar(15)
, @Phone varchar(50)
, @EmailId varchar(100)

)
AS
DECLARE @Message varchar(100)
IF(@EnquiryId=0)
BEGIN
IF EXISTS(SELECT * FROM Enquiry WHERE EnquiryNo=@EnquiryNo)
SET @Message='Record Exists In Database...!'

ELSE
BEGIN
INSERT INTO Enquiry
(
[EnquiryNo]
,[ClientId]
,[ContactPerson]
,[Desig]
,[Mobile]
,[Phone]
,[EmailId]
)
VALUES
(
@EnquiryNo
,@ClientId
,@ContactPerson
,@Desig
,@Mobile
,@Phone
,@EmailId
)
SELECT @EnquiryId = @@IDENTITY;
END
END
ELSE
BEGIN
UPDATE Enquiry
SET [EnquiryNo] = @EnquiryNo
,[ClientId] = @ClientId
,[ContactPerson] = @ContactPerson
,[Desig] = @Desig
,[Mobile] = @Mobile
,[Phone] = @Phone
,[EmailId] = @EmailId
WHERE EnquiryId = @EnquiryId

END
SELECT @EnquiryId


Thanks & Regards
Santosh Singh