S
Swetha
Hello
I have a DropDownList that I am populating using the following
SqlDataSource:
<aspropDownList ID="parentIDDropDownList" runat="server"
DataSourceID="SqlDataSource3" DataTextField="name"
DataValueField="ID"></aspropDownList><asp:SqlDataSource
ID="SqlDataSource3" runat="server" ConnectionString="<%$
ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT [ID], [name] FROM [client]
ORDER BY [name]"></asp:SqlDataSource>
Before I assign SelectedValue for this DropDownList, I need to add
another Item to it. This I do in the FormView's DataBound EventHandler.
protected void FormView1_DataBound(object sender, EventArgs e)
{
if(FormView1.CurrentMode == FormViewMode.Edit)
{
DropDownList myDdl =
(DropDownList)(FormView1.FindControl("parentIDDropDownList"));
if (myDdl != null)
{
myDdl.Items.Insert((myDdl.Items.Count), new
ListItem("Select a parent", "0"));
// Wish to assign myDdl.SelectedValue here
// myDdl.SelectedValue=SqlDataSource3.????
}
}
}
After inserting the "Select a Parent" Item, I wish to assign the
SelectedValue of the DropDownList to the corresponding value returned
by SqlDataSource3. How can I do this?
Thanks!
I have a DropDownList that I am populating using the following
SqlDataSource:
<aspropDownList ID="parentIDDropDownList" runat="server"
DataSourceID="SqlDataSource3" DataTextField="name"
DataValueField="ID"></aspropDownList><asp:SqlDataSource
ID="SqlDataSource3" runat="server" ConnectionString="<%$
ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT [ID], [name] FROM [client]
ORDER BY [name]"></asp:SqlDataSource>
Before I assign SelectedValue for this DropDownList, I need to add
another Item to it. This I do in the FormView's DataBound EventHandler.
protected void FormView1_DataBound(object sender, EventArgs e)
{
if(FormView1.CurrentMode == FormViewMode.Edit)
{
DropDownList myDdl =
(DropDownList)(FormView1.FindControl("parentIDDropDownList"));
if (myDdl != null)
{
myDdl.Items.Insert((myDdl.Items.Count), new
ListItem("Select a parent", "0"));
// Wish to assign myDdl.SelectedValue here
// myDdl.SelectedValue=SqlDataSource3.????
}
}
}
After inserting the "Select a Parent" Item, I wish to assign the
SelectedValue of the DropDownList to the corresponding value returned
by SqlDataSource3. How can I do this?
Thanks!