Setting image for GridImageColumn in ItemDataBound Codebehind

by ebarcza 3/15/2012 12:20:00 PM
    protected void rgDeals_ItemDataBound(object sender, GridItemEventArgs e)
        if (e.Item is GridDataItem)
            CheckBox chkDealLocked = (CheckBox)e.Item.FindControl("chkDealLocked");
            CheckBox chkComponentsLocked = (CheckBox)e.Item.FindControl("chkComponentsLocked");
            DataRowView drv = (DataRowView)e.Item.DataItem;
            int missingVolDays = Convert.ToInt32(drv["MissingVolumeDays"].ToString());
            GridDataItem item = (GridDataItem)e.Item;  
            Image img = (Image)item["Actualized"].Controls[0];
            if (missingVolDays != 0)
                img.Visible = false;
                chkDealLocked.Enabled = false;
                chkComponentsLocked.Enabled = false;
                img.ImageUrl = "~/Images/checkmark_blue.gif " ; 
                chkDealLocked.Enabled = true;
                chkComponentsLocked.Enabled = true;


.NET | Telerik

Visual Studio Clean Solution - what is does

by ebarcza 3/14/2012 7:20:00 AM
It deletes all the object code generated during previous compilation/build. It deletes the kind of files listed below: 

*.obj - object code 

*.pdb - program debug databse file

*.bsc - source browser databse 

*.ilk - incremental linker file

*.sbr - source browser intermediate file

*.idb - rebuild dependency file

*.lib - library file

*.exe - executable

BOOM - your solution is clean

rebuild all does the same damn thing



Telerik Radcombobox multiple selections with Checkboxes Server Side

by pencilvac 3/13/2012 12:09:00 PM

The Telerik Radcombobox control is great for selecting single values from a drop down list, but with the new addition of the control's CheckBoxes property adding checkboxes and allowing users to make multiple selections is quite easy.

First you need a radcombobox control:

<telerik:RadComboBox ID="rcbServiceTypes"  runat="server" CheckBoxes="True" />

Something to keep in mind: Right from the Telerik Doc's:

  • MarkFirstMatch and Filter functionalities are not supported. The reason is that the CheckBox selection is different from the standard RadComboBox's selection - there is no single selected item.
  • Load On Demand functionality is not supported. The reason is that RadComboBox's items loaded on demand are not accessible on the server which is needed for the CheckBox feature

Databind the control just like you would any other dropdownlist:

 private void LoadDropDownLists()


           //databind the radcombobox with values from your database

            rcbServiceTypes.DataSource = Utility.GetLookups(9);
            rcbServiceTypes.DataTextField = "LU_Value";
            rcbServiceTypes.DataValueField = "ID";

            //preselect a default values checkbox if you want

            RadComboBoxItem item1 = new RadComboBoxItem();
            item1 = rcbServiceTypes.Items.FindItemByValue("49");
            item1.Checked = true;


When you want to access the values that the user has checked off from the combobox in the code behind you can do something like this:

                   //create an array to store service types checked in the drop down

                    int itemschecked = rcbServiceTypes.CheckedItems.Count;      //the total boxes that were checked
                    String[] ServiceTypesArray = new String[itemschecked];        //an array to store the values

                    //now lets loop through the service types and get their value
                    var collection = rcbServiceTypes.CheckedItems;    //this variable holds all of the checked boxes so we can loop through
                    int i = 0;
                    foreach (var item in collection)

                       String value = item.Value; //grab the current check boxes value , you can also use .text to grab the text of the item selected
                       ServiceTypesArray[i] = value; //store it in the array
                    var ServiceTypes = String.Join(",", ServiceTypesArray); // If you need a String instead of an array then break the array into a comma separated string

Pretty easy to do.

NOTE: If you are having problems where your combobox.CheckedItems is coming up as 0 for a count but you are checking off boxes for sure then

make sure that some properties of your control on the front end are not interfering with the checkboxes property. The documentation on Telerik is not overly extensive.

Check out Teleriks documentation:

Telerik Radcombobox Checboxes Documentation

Tags: , , , ,

.NET | ASP.NET Enterprise Library | Telerik

C# running Access Query with parameters ADO

by ebarcza 3/13/2012 11:40:00 AM
 public DataTable GetFirmwareByBoardID(int boardID)
            GalleryDatabase db = DataBaseFactory.getDataBase(DataBaseName);
            OleDbCommand cmd = new OleDbCommand();
            cmd.Connection = new OleDbConnection(db.GetConnection().ConnectionString);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "qryGetFirmwareByBoardID";
            cmd.Parameters.AddWithValue("@prodCode", boardID);
            OleDbDataAdapter da = new OleDbDataAdapter(cmd);
            DataTable dt = new DataTable();
            return dt;


.NET | Access

Merging Data Tables in C#

by pencilvac 3/9/2012 12:16:00 PM

Merging data tables in C# is incredibly easy. If you have two tables of data pulled from the database:

In this situation our two tables have the same columns.

using System.Data; //include in your code behind so you can use data tables.


DataTable dt = Contract.GetDealContracts(pCompanyID, -1,42);

DataTable dt2 = Contract.GetDealContracts(pCompanyID, -1, 40);



You can then merge the two tables into one by simply:

dt.Merge(dt2); // table1.Merge(table2);


BOOM- two tables, now one table, with all your data. 

Tags: , , ,

.NET | ASP.NET Enterprise Library

Format Date on SSRS RDL

by ebarcza 3/6/2012 4:40:00 AM

Here's how to format a date on an RDL.

1.)Right Mouse click on the text box in the RDL
2.)Choose Text box properties
3.)In the list on the left hand side, choose number
4.)You'll see a list of categories - choose date
5.)Pick the format you desire and then hit OK


Powered by BlogEngine.NET
Theme by Mads Kristensen

About the author

Name of author Author name
Something about me and what I do.

E-mail me Send mail


<<  September 2022  >>

View posts in large calendar

Recent comments



The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2022

Sign in