TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
dattatray gaikwad
1.6k
172
572
Bind Drop down list
Sep 22 2017 2:18 PM
Hi Friends I am trying to bind drop down from database. I am getting data from database by calling wep api using HTTP service. Below is my code
1. To get data from database
public string ds2json()
{
sqlCommand.CommandText = "Select Id,Monthname From tbl_month";
sqlCommand.CommandType = CommandType.Text;
// Use connection object of base class
sqlCommand.Connection = MainConnection;
SqlDataAdapter adapter = new SqlDataAdapter();
DataSet ds = new DataSet();
adapter.SelectCommand = sqlCommand;
MainConnection.Open();
adapter.Fill(ds);
return JsonConvert.SerializeObject(ds, Formatting.Indented);
}
2. Web Api
$http.get('/api/Common/Get/')
.then(function (responce) {
$scope.Months = responce.data;
})
When I called web api I got below json data
{
"Table": [
{
"Id": 1,
"Monthname": "Apr"
},
{
"Id": 2,
"Monthname": "May"
},
{
"Id": 3,
"Monthname": "Jun"
},
{
"Id": 4,
"Monthname": "Jul"
},
{
"Id": 5,
"Monthname": "Aug"
},
{
"Id": 6,
"Monthname": "Sep"
},
{
"Id": 7,
"Monthname": "Oct"
},
{
"Id": 8,
"Monthname": "Nov"
},
{
"Id": 9,
"Monthname": "Dec"
},
{
"Id": 10,
"Monthname": "Jan"
},
{
"Id": 11,
"Monthname": "Feb"
},
{
"Id": 12,
"Monthname": "Mar"
}
]
}
I need to bind this Id as value and Month name as text for drop down in angular js.
May be my problem with multiple objects in this data
"Table": [{} ],"Table1": [{} ]
Reply
Answers (
1
)
Date functionality Issue
Angular function call to ASP.net web method