SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
up vote 0 down vote accepted

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;
share|improve this answer
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 '13 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. – trgraglia Jan 30 '13 at 9:29

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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