dropdown selectedvalue won't set

G

Guest

hey all,
can someone please tell me why the following statment doesn't work?

((DropDownList)e.Row.Cells[2].FindControl("DrpSM_Skill_Desc")).SelectedValue=((DataRowView)e.Row.DataItem)[3];
Cannot implicitly convert type 'object' to 'string'. An explicit conversion
exists (are you missing a cast?)

I'm in the Immediate Window doing this and also the following looks like it
would set a dropdownlist.selectedvalue?

?((DataRowView)e.Row.DataItem)[3]
"Internet"

Thanks,
rodchar
 
G

Guest

Nevermind I think, here's what learned
((DropDownList)e.Row.Cells[2].FindControl("DrpSM_Skill_Desc")).SelectedValue=(String)(((DataRowView)e.Row.DataItem)[3]);
 
O

Onwuka Emeka

emm ... you could also do

((DropDownList)e.Row.Cells[2].FindControl("DrpSM_Skill_Desc")).SelectedValue=((DataRowView)e.Row.DataItem)[3].ToString();

rodchar said:
Nevermind I think, here's what learned:
((DropDownList)e.Row.Cells[2].FindControl("DrpSM_Skill_Desc")).SelectedValue=(String)(((DataRowView)e.Row.DataItem)[3]);

rodchar said:
hey all,
can someone please tell me why the following statment doesn't work?

((DropDownList)e.Row.Cells[2].FindControl("DrpSM_Skill_Desc")).SelectedValue=((DataRowView)e.Row.DataItem)[3];
Cannot implicitly convert type 'object' to 'string'. An explicit
conversion
exists (are you missing a cast?)

I'm in the Immediate Window doing this and also the following looks like
it
would set a dropdownlist.selectedvalue?

?((DataRowView)e.Row.DataItem)[3]
"Internet"

Thanks,
rodchar
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,430
Messages
2,571,676
Members
48,796
Latest member
Greg L.

Latest Threads

Top