Thursday, August 22, 2013

Old Data Grid --- I cannot believe I am posting this old technology, but good to know and remember

The following is VB.NET I am currently on a contract programming both VB.NET and C# at the same time.  Does not make for a dull day.  However I had the code wrong with the following and wanted to be sure I blogged about the fix.

When calling the "SelectedIndexChange" Event on an old Data Grid be sure to declare a Int32
and by the way Int32 = Integer (Same thing).

Dim an index variable to hold the index as show below then get the DataKeys(index). Be sure
to convert to and Integer....

Protected Sub dg_Mygrid_SelectedIndexChanged(sender As Object, e As EventArgs)
        
        Dim index As Int32 = dg_Mygrid.SelectedIndex
        Dim intMy_ID As Int32

        intMy_ID = Convert.ToInt32(dg_Mygrid.DataKeys(index)) 
        FillForEditing(intMy_ID)
Post a Comment