Monday, February 27, 2012

convert more then value to comma separte value in sql server

 DECLARE @choices varchar(5000) 
 set @choices = '' 
 select @choices = @choices + (cp.DefaultCaption + ', ' ) from test qc  left outer join test1c on  qc.ChoiceID = c.ChoiceID left outer join test2 cp on cp.CaptionID = c.CaptionID              
 where qc.QuestionnaireID  in(@questionnaireId )
 if(len(@choices)>0) 
 BEGIN 
    set @choices = substring(@choices, 0 ,len(@choices)) 
 END 
print @choices

Wednesday, February 22, 2012

Start with the sequence of non-zero digits 123456789. The problem is to place plus or minus signs between them so that the result of thus described arithmetic operation will be 100.

Start with the sequence of non-zero digits 123456789. The problem is to place plus or minus signs between them so that the result of thus described arithmetic operation will be 100.
1 + 2 + 34 - 5 + 67 - 8 + 9 = 100
12 + 3 - 4 + 5 + 67 + 8 + 9 = 100
123 - 4 - 5 - 6 - 7 + 8 - 9 = 100
123 + 4 - 5 + 67 - 89 = 100
123 + 45 - 67 + 8 - 9 = 100
123 - 45 - 67 + 89 = 100
12 - 3 - 4 + 5 - 6 + 7 + 89 = 100
12 + 3 + 4 + 5 - 6 - 7 + 89 = 100
1 + 23 - 4 + 5 + 6 + 78 - 9 = 100
1 + 23 - 4 + 56 + 7 + 8 + 9 = 100
1 + 2 + 3 - 4 + 5 + 6 + 78 + 9 = 100

Validate check boxex in gridview with confirmation

    <script language="javascript" type="text/javascript">
        function validateChkBox() {
          var isValid = false;
            var gridView = document.getElementById('ctl00_ContentPlaceHolder111_grd_ctl00');

            for (var i = 1; i < gridView.rows.length; i++) {
                var inputs = gridView.rows[i].getElementsByTagName('input');
                if (inputs != null) {
                    if (inputs[0].type == "checkbox") {
                        if (inputs[0].checked) {
                            isValid = true;
                            return confirm('You are about to delete the user.  Are you sure you wish to continue?')

                        }
                    }
                }
            }
            alert("Please select at least one checkbox");
            return false;
        }

    </script>

Wednesday, February 15, 2012

Generate Xml from code behind using soap function

 using System.Xml;
 using System.Xml.Serialization;
 using System.Runtime.Serialization.Formatters.Soap;


-----------------------------------------------
MemoryStream stream1 = new MemoryStream();
        new SoapFormatter().Serialize(stream1, "hi");
        stream1.Position = 0;
        StreamReader reader1 = new StreamReader(stream1);
           string a=  reader1.ReadToEnd().ToString();