Pages

Monday 24 March 2014

Get single column from DataTable in C#

Description:  

   Here I retrieved all program details into the DataTable named dtProgrammes using Store Procedure. But I want only selected columns instead of all. So following code is used which retrieve all data the data on 0th indexed and 4th indexed column.

Code:

            DataTable dtProgrammes=bizGraphicsClipMap.GetAllProgrammes(channelId,date);

            List<string> stTime = dtProgrammes.AsEnumerable().Select(X => X[0].ToString()).ToList();
            List<string> endTime = dtProgrammes.AsEnumerable().Select(x => x[2].ToString()).ToList();

No comments:

Post a Comment