Lake County .NET Users' Group Helping the .NET developers of Lake County, Illinois

  • Find the cell in a GridViewRow that owns a given control

    Kurt Schroeder shares this gem to show how to find a given control ID in a GridViewRow:

        public static int GetCellPosition(GridViewRow gvr, string ctrlID)

        {

            for (int i = 0; i < gvr.Cells.Count; i++)

            {

                foreach (Control c in gvr.Cells[i].Controls)

                {

                    if (c.ID == ctrlID)

                        return i;

                }

            }

            return -1;

        }

     

    Full story

    Comments (9)

  • A function that converts from camel case to a phrase

    From Kurt Schroeder:

     

    namespace Iknowtek.Utils

    {

        public static class GeneralUtilities

        {

            /// <summary>

            /// will insert a space before each capital letter Kurt Schroeder 20080617

            /// Created to deal with enums

            /// example: var str  = GeneralUtilities.SpacedOutCamelCase(   Enum.GetName(typeof(BillingCycle), p.IBillingCycle),1 ));    

     

            /// </summary>

            /// <param name="str"></param>

            /// <param name="idx"></param>

            /// <returns></returns>

            public static string SpacedOutCamelCase(string str, int idx)

            {

                if (idx == str.Length)

                    return str;

                if (str[idx].ToString() == str[idx].ToString().ToUpper())

                    str = str.Substring(0, ++idx - 1) + " " + str.Substring(idx - 1, (str.Length - idx + 1));

                str = SpacedOutCamelCase(str, ++idx);

                return str;

            }

     

     

        }

    }

     

    Full story

    Comments (99)

  • Test

    Type your content here... test

    Full story

    Comments (17)