Wednesday, April 29, 2015

SQL Insert mutiple values to table

Database - Insert into mst_type(work_type_id,sub_work_type,record_status,create_user,create_stamp,update_user,update_stamp)
values (9,'Primary','A','system',GETDATE(),'system',GETDATE()),
(9,'Center','A','system',GETDATE(),'system',GETDATE()),
(9,'Medical','A','system',GETDATE(),'system',GETDATE()),
(9,'Staff','A','system',GETDATE(),'system',GETDATE()),
(9,'Aanganwadi','A','system',GETDATE(),'system',GETDATE()),
(9,'School','A','system',GETDATE(),'system',GETDATE()),
(9,'Village','A','system',GETDATE(),'system',GETDATE()),
(9,'Samajik Sabhagruha','A','system',GETDATE(),'system',GETDATE()),
(9,'Shopping Center Building','A','system',GETDATE(),'system',GETDATE()),
(9,'Veternary Hospital','A','system',GETDATE(),'system',GETDATE()),
(9,'Mahila Work Shed Building','A','system',GETDATE(),'system',GETDATE()),
(9,'Product Selling Stall','A','system',GETDATE(),'system',GETDATE()),
(9,'Office Building','A','system',GETDATE(),'system',GETDATE()),
(9,'Staff Quarter Building','A','system',GETDATE(),'system',GETDATE()),
(9,'Smashan Bhumi','A','system',GETDATE(),'system',GETDATE()),
(9,'Toilet Blocks','A','system',GETDATE(),'system',GETDATE()),
(10,'Major Bridge','A','system',GETDATE(),'system',GETDATE()),
(10,'Minor Bridge','A','system',GETDATE(),'system',GETDATE()),
(10,'Culverts','A','system',GETDATE(),'system',GETDATE())

SQL add column to table


alter table trn
add sub_wo int

Tuesday, April 28, 2015

asp.net dropdown change hide show html div

   $('#<%= ddl.ClientID %>').change(function () {
                var selectedvalue = $(this).val();
             
                if (selectedvalue == 1) {
                    $("#divContractorName").show();
                }
                else {
                    $("#divContractorName").hide();
                }
            });


   <div id="divContractorName" class="wd33percommuNew lFloat " style="display: none;">
                                Hello world
                                </div>

SQL if value is not passing to stored procedure make it null

1) If Name field in form is empty then stored procedure will give error because it is expecting parameter name.

2) So to resolved this error modify stored procedure like below

ALTER procedure procedrename
(
   @name nvarchar = null
)

SQL get stored procedure body by name

sp_helptext yourStoredProcedureName

assigning Null value to datetime in C#

Since DateTime is a value type (like int), a Null value cannot be assigned to it.

DateTime? dateSample;
dateSample.Value = null;
//or 
Nullable<DateTime> dateSample2;
dateSample2.Value = null;

Backspace or Delete key In TextBox with Masked Edit Extender in ASP.NET not working

1) Create MaskedEditFix.js File

(function(){try{var n=Sys.Extended.UI.MaskedEditBehavior.prototype,t=n._ExecuteNav;n._ExecuteNav=function(n){var i=n.type;i=="keydown"&&(n.type="keypress"),t.apply(this,arguments),n.type=i}}catch(i){return}})()

2) Add to .cs file

 protected void Page_Init(object sender, EventArgs e)
        {
            if (!ClientScript.IsStartupScriptRegistered(GetType(), "MaskedEditFix"))
            {
                ClientScript.RegisterStartupScript(GetType(), "MaskedEditFix", String.Format("<script type='text/javascript' src='{0}'></script>", Page.ResolveUrl("../Scripts/MaskedEditFix.js")));
            }
        }

3) Then check