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
shubham bhardwaj
1.7k
18
5.2k
Unable to cast the object type System.-.generic.keyvaluepair
Nov 28 2014 11:54 PM
Unable to cast the object type System.-.generic.keyvaluepair into system.iconvertible
here is my code
private void LoadUniversity()
{
try
{
ObjUtility = new Utility();
cmbUniversity.DataSource = ObjUtility.BindUniversity(StaticInfo.Center_Code).ToList();
//////////error is after this line (May be in BindUniversity method )///////////
cmbUniversity.DisplayMember = "Value";
cmbUniversity.ValueMember = "Key";
cmbUniversity.SelectedIndex = -1;
cmbUniversity.Text = "--Select University--";
ObjUtility = null;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
I am also giving here BindUniversity() method which is in Utility class ... here it is:------
public Dictionary<string, string> BindUniversity(string CenterCode)
{
ObjUniversityInfoModel = new UniversityInfoModel();
ObjUniversityInfoModel.CenterCode = CenterCode;
ObjUniversityInfoServiceClient = new UniversityInfoServiceClient();
ObjUniversityInfoModelRecordList = new List<UniversityInfoModel>();
ObjUniversityInfoModelRecordList = ObjUniversityInfoServiceClient.GetUniversityInfoRecordList(ObjUniversityInfoModel);
if (ObjUniversityInfoModelRecordList[0].Message == "Success" && ObjUniversityInfoModelRecordList[0].Status == true)
{
var Result = from s in ObjUniversityInfoModelRecordList
orderby s.UniversityID descending
select new
{
s.UniversityID,
s.UniversityName
};
ObjDictionary = new Dictionary<string, string>();
foreach (var Item in Result)
{
string U_ID = Item.UniversityID.ToString();
string U_Name = Item.UniversityName.ToString();
ObjDictionary.Add(U_ID, U_Name);
}
}
return ObjDictionary;
}
Help me....
Reply
Answers (
1
)
Queue Program
License key in c#.net desktop application