I am using c# and I have a SPList with fields such Title and Translation. I want to set Word and Translation into SPGridview.

I can retrieve data from my List:

string translation = (string)itemfields["Translation"];
string word = (string)itemfields["Title "];

So, I need put it into SPGridview and if user selects right variant of word - translation to change background color and delete from table. Of course word - translation should be in different(random) position (in different 'tr' ). Any useful link will be greatly appreciated. Thanks.

1 Answer 1


As for getting items from the SPList to the GridView, do an SPQuery for the items you want to display. Once you have the SPListItemCollection from the query, get the DataTable from it and bind to the GridView.

DataTable table = items.GetDataTable();
GridView1.DataSource = table;
  • Thanks! I ve used following and it solved my problem var spQuery = new SPQuery(); SPFolder folder = list.RootFolder.SubFolders[ListSelectedFolder]; spQuery.Folder = folder; SPListItemCollection FolderItems = list.GetItems(spQuery); table = new DataTable(); table.Columns.Add("Words"); table.Columns.Add("Translations"); ................. GameRepeater.DataSource = table; GameRepeater.DataBind();
    – shakizat
    Jan 30, 2013 at 4:09
  • Glad it helped. Also, on Stack Exchange sites, please do not forget to mark answers as accepted if they helped. This lets other people know that the answer works and is correct. Jan 30, 2013 at 9:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.