Connecting Tech Pros Worldwide Help | Site Map

set selectedvalue on dropdown in datagrid

Kurt Schroeder
Guest
 
Posts: n/a
#1: Nov 19 '05
I have a datagrid that includes a dropdown in an edit template. It creates
ok, but i'm not sure how to set the selectedvalue based on the table in the
dataset.
given that the dataset DsSubTypes1 what is the best way to get the current
value. If it can be taken from the datagrid i'd like to know how.
My sub to populate the dropdownlist is below.
thanks
kes
If e.Item.ItemType = ListItemType.EditItem Then
Dim thsddl As DropDownList =
e.Item.Cells(4).Controls(0).FindControl("ddlTF")
thsddl.DataSource = DsSubTypes1
thsddl.DataTextField = "TFDesc"
thsddl.DataValueField = "TFValue"
thsddl.DataBind()

'thsddl.SelectedValue =
End If
Kurt Schroeder
Guest
 
Posts: n/a
#2: Nov 19 '05

re: set selectedvalue on dropdown in datagrid


Ok I can get it to work, but i'm using a hidden databound column. Is there a
better way?

"Kurt Schroeder" wrote:
[color=blue]
> I have a datagrid that includes a dropdown in an edit template. It creates
> ok, but i'm not sure how to set the selectedvalue based on the table in the
> dataset.
> given that the dataset DsSubTypes1 what is the best way to get the current
> value. If it can be taken from the datagrid i'd like to know how.
> My sub to populate the dropdownlist is below.
> thanks
> kes
> If e.Item.ItemType = ListItemType.EditItem Then
> Dim thsddl As DropDownList =
> e.Item.Cells(4).Controls(0).FindControl("ddlTF")
> thsddl.DataSource = DsSubTypes1
> thsddl.DataTextField = "TFDesc"
> thsddl.DataValueField = "TFValue"
> thsddl.DataBind()
>
> 'thsddl.SelectedValue =
> End If[/color]
Closed Thread