dropdown selectedvalue won't set

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
Nevermind I think, here's what learned
((DropDownList)e.Row.Cells[2].FindControl("DrpSM_Skill_Desc")).SelectedValue=(String)(((DataRowView)e.Row.DataItem)[3]);
 
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
 
Back
Top