if (!Page.IsPostBack)
{
using (SPSite site = new ("http://yoursharepointsite"))
{
using (SPWeb web = site.OpenWeb())
{
SPList list = web.Lists["NameOfYourList"];
dropSite.DataSource = list.Items;
dropSite.DataValueField = "Title"; // List field holding value - first column is called Title anyway!
dropSite.DataTextField = "Title"; // List field holding name to be displayed on page
dropSite.DataBind();
}
}
}
Method 2:- Using SPDataSource
Hi Deepak, I have a requiresment that I have to there is a need for dropdownlist in the aspx page and a column data should appear in that dropdown from a list. I want a jquery to bind the list and dropdownlist.
ReplyDeleteHi,
ReplyDeleteI'm trying to bind to a dropdown a datasource "AggregateDataSource" which is a linked source btween 2 sharepoint libraries, but it shows error page, however when I bind a document library it binds correctly,
any idea?
Hi,
ReplyDeleteDo you have any idea about how to show list columns in textbox using a selection from dropdown list control?
I have created a list named "emplist" with the columns emptitle, empname, empdesignation.
i have added some list items to this list.
for eg: 1. Mr. A developer
2. Mr. B designer
3. Mr. C programmer
and now i have created a visualwebpart in visual studio and i have taken controls from toolbox as :
Dropdownlist1, TextBox1, TextBox2, TextBox3.
First thing i want to do is to get the emplist items in that dropdownlist1. For this i wrote the code in page load as follows:
if (IsPostBack == false)
{
var web = SPContext.Current.Web;
var mylist = web.Lists["emplistnew"];
DropDownList1.DataSource = mylist.Items.GetDataTable();
DropDownList1.DataTextField = "EmpName";
DropDownList1.DataBind();
}
and it is working fine if i check.
Dropdownlist is showing that the Three empnames A, B, C.
My task is if i select 'A' from dropdownlist, i want to display the emptitle, empname, emp designation of that A in the textbox fields.
How to do this??
Could you explain how to save the selected value into a field in the sharepoint list?
ReplyDeleteI am creating a custom solution on SharePoint 2013 on-premise using Visual Studio 2012. I have a custom list called Postings. This list have 2 fields - Title (single line of text) and URL (hyperlink).
ReplyDeleteI have a drop-down list control which gets auto populated from "Title". I have a button next to this drop-down control. Based upon the selection in drop down list control, the new URL should open up when button is clicked. Basically, when a user selects an entry in drop down list control and click the button, the URL corresponding to that selected entry should open up in new tab.
I have the drop-down list auto-populated and working fine. I need to know how to open up corresponding URL based upon selection from drop down list.