Friday, September 28, 2012

RadListBox - Multi Select With Select All Option

This article will show you how to have an item which checks/unchecks all items. 

Select All  OR Un Select All  - sing Rad Combo / List Box Control

The aspx File

<script language="javascript" type="text/javascript">
    function OnClientItemChecked(sender, eventArgs) {
        var lstBoxControl;
        lstBoxControl = $find(sender.get_id());
        var items = lstBoxControl.get_items();
        if (eventArgs.get_item().get_index() == 0) {
            var firstIndex = eventArgs.get_item().get_checked();
            for (var i = 0; i < lstBoxControl.get_items().get_count(); i++) {

                items.getItem(i).set_checked(firstIndex);
            }
        }
        else {
            items.getItem(0).set_checked(false);
        }
    }
</script>

<telerik:RadListBox AppendDataBoundItems="true" TabIndex="1" Width="200px" CheckBoxes="true" ID="lstClassificationTypes" DataSourceID="dataClassificationTypes" runat="server" DataTextField="SelectionName" DataValueField="SelectionId" OnClientItemChecked="OnClientItemChecked">
<Items>
<telerik:RadListBoxItem Text="Select / UnSelect All" Value=0 BackColor=Gray Font-Bold="true" ForeColor=White />
</Items>
</telerik:RadListBox> 


The aspx.cs File

Find Selected Item

protected void btnGenerate_Click(object sender, EventArgs e)
    {
        StringBuilder sb = new StringBuilder();
        IList<RadListBoxItem> collection = ((RadListBox)fview.FindControl("lstClassificationTypes")).CheckedItems;

        foreach (RadListBoxItem item in collection)
        {
            // Your Code Here >> item.Value
        }
    }

If you need additional assistance, do not hesitate to contact me.@ tkjagadheesh@gmail.com

Regards,
JAG

Tags: RadListBox, C#, CheckBox, Java Script, Multiple Items, ASP.NET, AJAX, Rad Controls check all, Un check all, Select all, Multi Select Combo, MultiSelect List Box

TSQL / SQL Calculating Cumulative Total

Calculating a moving cumulative total using TSQL statement.

The OVER clause defines a window or user-specified set of rows within a query result set. A window function then computes a value for each row in the window. 
You can use the OVER clause with functions to compute aggregated values such as moving averages, cumulative aggregates, running totals, or a top N per group results.


SELECT BusinessEntityID, TerritoryID 
   ,DATEPART(yy,ModifiedDate) AS SalesYear
   ,CONVERT(varchar(20),SalesYTD,1) AS  SalesYTD
   ,CONVERT(varchar(20),AVG(SalesYTD) OVER (PARTITION BY TerritoryID 
                                            ORDER BY DATEPART(yy,ModifiedDate) 
                                           ),1) AS MovingAvg
   ,CONVERT(varchar(20),SUM(SalesYTD) OVER (PARTITION BY TerritoryID 
                                            ORDER BY DATEPART(yy,ModifiedDate) 
                                            ),1) AS CumulativeTotal
FROM Sales.SalesPerson
WHERE TerritoryID IS NULL OR TerritoryID < 5
ORDER BY TerritoryID,SalesYear;

--
Jagadeesan Kandasamy


Wednesday, May 30, 2012

MS Excel Transpose Rows and Columns

Tags:

Convert Row to a Column in Excel

Excel rows to columns

Switch Excel Columns to Rows

MS Excel Change Row into Column

Convert Rows to Columns and Columns to Rows in Excel

How to Convert Rows to Columns in Excel?

How to Convert Columns to Rows in Excel?

Transpose Excel Rows and Columns

MS Excel transpose data from rows to columns OR columns to rows

 

Step 1:

 

Select the table or colums & rows you wish to flip.

 

 

 

 

Step 2:

 

Copy the entire table and click Pate >> Paste Special.

 

 

 

 

 

Step 3:

 

Select the Transpose Check box.

 

 

 

 

 

Step 5:

 

All done here is the result..

 

 

 

 

Posted By

Jagadeesan Kandasamy


Friday, January 20, 2012

First date of a week using SQL

How to get the first date / day in a week using SQL Server.?



The example gets the date of the first day in the week that GETDATE() is in.

SELECT DATEADD(ww, DATEDIFF(ww,0,GETDATE()), 0)

It's yery simple and quite elegant,  Happy Coding!! :)