I have a sharepoint list named Products with the following columns:

  • ProductID
  • Name
  • Price.

In ASPX page there are 3 text boxes that will hold the data for each corresponding column as shown below:

textbox1 = productID

textbox2 = Name

textbox3 = Price

The list has 3 products registered with appropriate data. The text boxes in the ASPX page should be populated with data for each product. The data has to be retrieved from the list and bound to the text box using C#.


Use the following code to get all items from the list. Once you have the ListItemCollection, you can access value of each list item and bind it to the text box.

 SPWeb web = SPContext.Current.Web;
 SPList docList = web.Lists.GetList(enter list ID here, true);
 SPListItemCollection items = docList.GetItems();
 foreach(SPItem item in items)
     textbox1.text = item.ID;
     textbox1.text = item["Name"];
     textbox1.text = item["Price"]; 
  • where can i get list ID @Mancy – Nderon Hyseni Nov 2 '15 at 10:10
  • Please refer to my answer here - sharepoint.stackexchange.com/questions/161186/…, you will be able to get List Id. – Mancy Desaee Nov 2 '15 at 11:09
  • 1
    something is not going well, i have 3 product on the list witth the following info: ID: 1 Name: Mouse Price: 6 ID: 2 Name: Keyboard Price: 7 ID: 3 Name: Hardrive Price: 50 if textbox1 contain id 1 i want textbox2 to show mouse and textbox 3 to show 6, else if textbox1 contain id 2 i want textbox2 to show keyboardand textbox 3 to show 7, and so on... – Nderon Hyseni Nov 3 '15 at 8:54
  • I understand this. In order to implement this you would need to have a dropdown for the IDs. As per the selection of the ID you can display the relevant price and product name. – Mancy Desaee Nov 3 '15 at 9:07
  • 1
    Do you mean to say that you want the single text box to display value for Id: 1 ,2 ,3? – Mancy Desaee Nov 3 '15 at 9:40

You can retrieve the SharePoint list data using client-object model in ASPX page very easily. here is the link to Access SharePoint list data using Client Object Model

  • Helpful answer.. – Ronak Patel Nov 2 '15 at 9:31
  • 3
    Please always share some code snippet if you are pointing to an external link. – Taran Goel Nov 2 '15 at 9:51

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.