Showing posts with label dropdownlist. Show all posts
Showing posts with label dropdownlist. Show all posts

Wednesday, March 28, 2012

Pre selected item in a cascading dropdownlist

I have a set of 3 dropdowns that im using the cascading dropdownlist ajax with. They all load corectly with the webservice and work great, but the form is an inventory entry screen and I need to update an existing inventory sometimes. So is there a way to pre-select all 3 dropdown list boxes? I tried "CascadingDropDown1.SelectedValue = "MACK";" but it gets erased when the webservise returns the data.


Maybe you got it solve by the date, but i figure out a way to lead with cascadingDropdownlist and preselection.
In my case I have 3 dropdownlist (ddl) inside a formview and depending is a session variable is already filled the value for the first DDL (parent) is changed.

In the following code, FvwPostOff is a formview which contents my DDL and CascadingDropDown (CddBuilding) extenders. The thing is to set the value by the CascadingDropdown extender instead of the DDL direclty:

ElseIf (Session("BUILD_NB") IsNotNothing)Then Try Dim CddBuildingAs CascadingDropDown = FvwPostOff.FindControl("CddBuilding") CddBuilding.SelectedValue = Session("BUILD_NB")Catch exAs IndexOutOfRangeException' nothingEnd Try End If
Hope this help

Monday, March 26, 2012

Prevent child control inside the updatepanel to refresh the updatepanel

let say i have 2 UpdatePanels UP1 and UP2. Up1 contains a dropdownlist with 3000 items. When selectedindex of the dropdownlist is changed, it fires a partial postback to refresh the controls inside the UP2 which uses trigger. but at the same time it also refreshes the UP1which i want to avoid. and i also need this dropdown list to be inside the Updatepanel because the selected index is changing during partial postback.

Currently what i have done is i took this dropdownList out of updatepanel and the UP2 gets refreshed using trigger of that dropdownlist, and when it is required to update the the dropdown list i 'm injecting the javascript code in partial postback to do this.

any better work around to achieve this.

Thanks in Advance

RG

Pushed...

Saturday, March 24, 2012

Problem creating binding for TextBox/AutoCompleteExtender and DropDownList/CascadingDropDo

I'm trying to use a textbox hooked up to an autocompleteextender todrive a DropDownList hooked up to a cascadingdropdown. I'm tryingto do this by creating a binding between the textbox and a hiddenDropDownList. The binding invokes a custom transform that updatesthe contents on the hidden dropdown with the text from the textbox whenthe textbox text changes. I am close, but I am running into someissues which I believe are due to the fact that my controls are insidean updatepanel. I'm getting the infamous Duplicate use of id...when the updatepanel reloads my textbox and autocompleteextender.

Here's the source. Can anyone offer any ideas? thanks...

<%@dotnet.itags.org. Page Language="C#" EnableEventValidation="false" %>
<%@dotnet.itags.org. Register Assembly="AtlasControlToolkit" Namespace="AtlasControlToolkit" TagPrefix="atlasToolkit" %
<script runat="server">

void AutoCompleteTextBox_PreRender(object sender, EventArgs e) {
((TextBox)sender).Attributes.Add("autocomplete", "off");
}

void Page_Load(object sender, EventArgs e) {

AccountTextBox.Visible = AccountRadioButton.Checked;
if (AccountRadioButton.Checked) {AccountAutoCompleteExtender.TargetProperties[0].Enabled = true; }
else {
AccountAutoCompleteExtender.TargetProperties.Clear();
CascadingDropDown1.TargetProperties.Clear();
}

LicenseTextBox.Visible = LicenseRadioButton.Checked;
LicenseDropDownList.Visible = !LicenseRadioButton.Checked;
if (LicenseRadioButton.Checked) {LicenseAutoCompleteExtender.TargetProperties[0].Enabled = true; }
else { LicenseAutoCompleteExtender.TargetProperties.Clear(); }

}

</script
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Untitled Page</title>

<script type="text/javascript">
<!-- //

var addl;
var atb;

function pageLoad(sender, e) {

atb = new Sys.UI.TextBox($("<%=AccountTextBox.ClientID %>"));
addl = new Sys.UI.Select($("<%=AccountDropDownList.ClientID %>"));

var addl_binding = new Sys.Binding();
addl_binding.set_dataContext(atb);
addl_binding.set_dataPath("text");
addl_binding.set_property("selectedValue");
addl_binding.transform.add(setDropDownList);

addl.get_bindings().add(addl_binding);

atb.initialize();
addl.initialize();
}

function setDropDownList(sender, eventArgs) {

// I WOULD HAVE LIKED TO HAVE CREATED AN INSTANCE OFTHE AtlasControlToolkit.CascadingDropDownNameValue,
// BUT COULDN'T SEEM TO FIGURE OUT HOW TO DO THAT...
var value = newDummy.CascadingDropDownNameValue(eventArgs.get_value(),eventArgs.get_value());

var cddp1 = $object("CascadingDropDownProperties1");
cddp1._setOptions([value]);

}

// -->
</script>

</head>
<body>
<form id="form1" runat="server">
<atlas:ScriptManager ID="ScriptManager1" EnablePartialRendering="true" runat="server" />

<atlas:AutoCompleteExtender ID="AccountAutoCompleteExtender" runat="server">
<atlas:AutoCompleteProperties Enabled="true" MinimumPrefixLength="2"ServiceMethod="GetAccountList" ServicePath="Lookup.asmx"TargetControlID="AccountTextBox" />
</atlas:AutoCompleteExtender
<atlas:AutoCompleteExtender ID="LicenseAutoCompleteExtender" runat="server">
<atlas:AutoCompleteProperties Enabled="true" MinimumPrefixLength="2"ServiceMethod="GetLicenseList" ServicePath="Lookup.asmx"TargetControlID="LicenseTextBox" />
</atlas:AutoCompleteExtender>

<atlasToolkit:CascadingDropDown ID="CascadingDropDown1" runat="server">
<atlasToolkit:CascadingDropDownPropertiesid="CascadingDropDownProperties1" TargetControlID="AccountDropDownList"Category="Account" PromptText="" ServicePath="~/FrontlineService.asmx"ServiceMethod="GetDropDownTextBoxContents" />
<atlasToolkit:CascadingDropDownPropertiesTargetControlID="LicenseDropDownList" Category="License"PromptText="Please select a License"ServicePath="~/FrontlineService.asmx"ServiceMethod="GetDropDownTextBoxContents"ParentControlID="AccountDropDownList" />
</atlasToolkit:CascadingDropDown>

<asp:Panel ID="LookupPanel" BackColor="#999999" CssClass="panel" runat="server">
<atlas:UpdatePanel ID="LookupUpdatePanel" Mode="Conditional"runat="server">
<ContentTemplate>
<div>
<table>
<tr>
<td rowspan="3"valign="top"><span style="font-weight: bold;">License LookupBy:</span></td>
<td>
<asp:RadioButtonID="AccountRadioButton" GroupName="Lookup" Checked="true"AutoPostBack="true" runat="server" /> Account
</td>
<td>
<asp:TextBoxID="AccountTextBox" OnPreRender="AutoCompleteTextBox_PreRender"runat="server" />
</td>
</tr>
<tr>
<td>
<asp:RadioButtonID="LicenseRadioButton" GroupName="Lookup" AutoPostBack="true"runat="server" /> License
</td>
<td>
<asp:TextBoxID="LicenseTextBox" OnPreRender="AutoCompleteTextBox_PreRender"runat="server" />
<asp:DropDownListID="AccountDropDownList" style="display: none;" runat="server"/>
<asp:DropDownListID="LicenseDropDownList" runat="server" />
</td>
</tr>
</table>
</div>

<scripttype="text/xml-script">
<pagexmlns:script="http://schemas.microsoft.com/xml-script/2005">
<components>
</components>
</page>
</script>

</ContentTemplate>
<Triggers>
<atlas:ControlEventTriggerControlID="AccountRadioButton" EventName="CheckedChanged" />
<atlas:ControlEventTriggerControlID="LicenseRadioButton" EventName="CheckedChanged"/>
</Triggers>
</atlas:UpdatePanel>

</asp:Panel>

</form
<script type="text/javascript">
<!-- //

Type.registerNamespace("Dummy");

Dummy.CascadingDropDownNameValue = function(name, value) {
var _name = name;
var _value = value;

this.name = _name;
this.value = _value;

}

Dummy.CascadingDropDownNameValue.registerClass('Dummy.CascadingDropDownNameValue');
// -->
</script
</body>
</htmlHave you tried FAQ #6?
I did read that, and I did try to apply the
var context = Sys.Application.getMarkupContext();
if (context) { context.removeObject(this); }

to the dispose method of the CascadingDropDownBehavior.js but it didn't seem to make a difference.

I'm stilling getting the Duplicate use for the AccountTextBox, CascadingDropDownProperties1 and AccountDropDownList...
I'm trying a slightly different approach, but I'm still running intosome issues. I'm trying to define the autocomplete behaviordeclaratively, instead of using an autocompleteextender. everything works well, but when the updatepanel refreshes, theautocomplete behavior doesn't seem to exist anymore.

i tried placing the xml-script inside the updatepanel, too, no difference.

heres the code to reproduce:

<%@. Page Language="C#" EnableEventValidation="false" %
<%@. Register Assembly="AtlasControlToolkit" Namespace="AtlasControlToolkit" TagPrefix="atlasToolkit" %
<script runat="server">

void AutoCompleteTextBox_PreRender(object sender, EventArgs e) {
((TextBox)sender).Attributes.Add("autocomplete", "off");
}

</script
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Untitled Page</title
<script type="text/javascript">
<!-- //

function setDropDownList(sender, eventArgs) {

// I WOULD HAVE LIKED TOHAVE CREATED AN INSTANCE OF THEAtlasControlToolkit.CascadingDropDownNameValue,
// BUT COULDN'T SEEM TO FIGURE OUT HOW TO DO THAT...
var value = newDummy.CascadingDropDownNameValue(sender.get_text(), sender.get_text());

var cddp1 = $object("CascadingDropDownProperties1");
cddp1._setOptions([value]);

}

// -->
</script
</head>
<body>
<form id="form1" runat="server">
<atlas:ScriptManagerid="ScriptManager1" EnablePartialRendering="true" runat="server" />

<atlas:AutoCompleteExtender id="LicenseAutoCompleteExtender" runat="server">
<atlas:AutoCompleteProperties Enabled="true" MinimumPrefixLength="2"ServiceMethod="GetLicenseList" ServicePath="Lookup.asmx"TargetControlID="LicenseTextBox" />
</atlas:AutoCompleteExtender>

<atlasToolkit:CascadingDropDown ID="CascadingDropDown1" runat="server">
<atlasToolkit:CascadingDropDownPropertiesID="CascadingDropDownProperties1" TargetControlID="AccountDropDownList"Category="Account" PromptText="" ServicePath="~/FrontlineService.asmx"ServiceMethod="GetDropDownContents" />
<atlasToolkit:CascadingDropDownPropertiesTargetControlID="LicenseDropDownList" Category="License"PromptText="Please select a License"ServicePath="~/FrontlineService.asmx"ServiceMethod="GetDropDownContents" ParentControlID="AccountDropDownList" />
</atlasToolkit:CascadingDropDown
<script type="text/xml-script">
<pagexmlns:script="http://schemas.microsoft.com/xml-script/2005">
<components>
<textBox id="AccountTextBox"propertyChanged="setDropDownList">
<behaviors>
<autoComplete completionInterval="1000"completionList="completionList" completionSetCount="15"
dataContext="AccountTextBox" minimumPrefixLength="2"serviceMethod="GetAccountList"
serviceURL="Lookup.asmx">
</autoComplete>
</behaviors>
</textBox>
</components>
</page>
</script
<asp:Panel ID="LookupPanel" BackColor="#999999" CssClass="panel" runat="server">
<atlas:UpdatePanel id="LookupUpdatePanel" mode="Conditional"runat="server">
<ContentTemplate>
<div>
<table>
<tr>
<td rowspan="3" valign="top"><spanstyle="font-weight: bold;">License Lookup By:</span></td>
<td>
<asp:RadioButton ID="AccountRadioButton"GroupName="Lookup" Checked="true" AutoPostBack="true" runat="server"/> Account
</td>
<td>
<asp:TextBox ID="AccountTextBox"OnPreRender="AutoCompleteTextBox_PreRender" runat="server" />
<div id="completionList"></div>
<asp:DropDownList ID="AccountDropDownList"style="display: none;" runat="server" />
</td>
</tr>
<tr>
<td>
<asp:RadioButton ID="LicenseRadioButton"GroupName="Lookup" AutoPostBack="true" runat="server" /> License
</td>
<td>
<asp:TextBox ID="LicenseTextBox"OnPreRender="AutoCompleteTextBox_PreRender" runat="server" />
<asp:DropDownList ID="LicenseDropDownList"runat="server" />
</td>
</tr>
</table>
</div>
</ContentTemplate>
<Triggers>
<atlas:ControlEventTriggerControlID="AccountRadioButton" EventName="CheckedChanged" />
<atlas:ControlEventTriggerControlID="LicenseRadioButton" EventName="CheckedChanged" />
</Triggers>
</atlas:UpdatePanel>
</asp:Panel>
</form
<script type="text/javascript">
<!-- //

Type.registerNamespace("Dummy");

Dummy.CascadingDropDownNameValue = function(name, value) {
var _name = name;
var _value = value;

this.name = _name;
this.value = _value;
}

Dummy.CascadingDropDownNameValue.registerClass('Dummy.CascadingDropDownNameValue');
// -->
</script
</body>
</html

Problem getting SelectedValue of Cascading DropDown inside a Gridview

I am trying to obtain the SelectedValue from a DropDownList which is controlled by a CascadingDropDown Control both of which are inside of a gridview. The cascading dropdowns are populating correctly. The SelectedValue is also set on these dropdowns in the OnRowDataBound event.

In the OnRowUpdating event, I am grabbing the dropdownlist's selected value from the updating row using:

string strID = ((

DropDownList)gvPositions.Rows[e.RowIndex].FindControl("ddlLineEdit")).SelectedValue;

When I do this, the value is always null.

I think it might be because you don't reference the cell but only the row. I have a similar example that does work:

DropDownList ddPanes = (DropDownList)grid.Rows[e.RowIndex].Cells[2].FindControl("ddPaneNames");

Hope it helps,

Joe
That was a good thought. I don't have to do that for the other controls in the row, but I tried it. Unfortunately that still give me null as well.
Can you post the markup for your gridview?

Here is my code:

<asp:GridView ID="gvPositions" runat="server" AutoGenerateColumns="False" Width="100%" OnRowEditing="gvEdit" OnRowCancelingEdit="gvCancel" OnRowUpdating="gvUpdate" OnRowCommand="gvItemCommand" OnRowDeleting="gvDelete" OnRowDataBound="gvRowDataBind"> <Columns> <asp:TemplateField HeaderText="positionID" Visible="False"> <ItemTemplate> <asp:Label runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.positionID")%>' ID="lblpositionID"> </asp:Label> </ItemTemplate> <EditItemTemplate> <asp:Label runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.positionID")%>' ID="lblpositionID"> </asp:Label> </EditItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="TDA Version"> <ItemTemplate> <asp:Label runat="server" Text='<%# Eval("tdaName")%>' ID="lbltdaNameGrid"> </asp:Label> </ItemTemplate> <EditItemTemplate> <asp:Label runat="server" ID="lbltdaNameEdit" CssClass="label" Width="100%" Text='<%# DataBinder.Eval(Container, "DataItem.tdaName")%>'> </asp:Label> <asp:DropDownList ID="ddlTDANameEdit" runat="server" AutoPostBack="false" DataSource='<%# GetTDAList()%>' SelectedValue='<%# Eval("tdaVersionID")%>' DataTextField="tdaName" DataValueField="tdaVersionID" ></asp:DropDownList> </EditItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Paragraph"> <ItemTemplate> <asp:Label runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.paragraphTitle")%>' ID="lblParagraphNameGrid"> </asp:Label> </ItemTemplate> <EditItemTemplate> <asp:Label runat="server" ID="lblParagraphEdit" CssClass="label" Width="100%" Text='<%# DataBinder.Eval(Container, "DataItem.paragraphTitle")%>'> </asp:Label> <asp:DropDownList ID="ddlParagraphEdit" runat="server" AutoPostBack="false"></asp:DropDownList> </EditItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Line"> <ItemTemplate> <asp:Label runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.lineTitle")%>' ID="lbltitleGrid"> </asp:Label> </ItemTemplate> <EditItemTemplate> <asp:Label runat="server" ID="lbltitleEdit" CssClass="label" Width="100%" Text='<%# DataBinder.Eval(Container, "DataItem.lineTitle")%>'> </asp:Label> <asp:DropDownList ID="ddlLineEdit" runat="server" AutoPostBack="false"></asp:DropDownList> <cc1:CascadingDropDown ID="CascadingDropDownGridView" runat="server" SuppressValidationScript="true"> <cc1:CascadingDropDownProperties TargetControlID="ddlParagraphEdit" ServiceMethod="GetParagraphsByTDAID" ServicePath="~/AutoCompleteService.asmx" PromptText="Please select a paragraph" Category="tdaVersionID" ParentControlID="ddlTDANameEdit" /> <cc1:CascadingDropDownProperties TargetControlID="ddlLineEdit" ServiceMethod="GetLinesByParagraphID" ServicePath="~/AutoCompleteService.asmx" PromptText="Please select a line" Category="tdaParagraphID" ParentControlID="ddlParagraphEdit" /> </cc1:CascadingDropDown> </EditItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Directorate"> <ItemTemplate> <asp:Label runat="server" ID="lblDirectorate" Text='<%# DataBinder.Eval(Container, "DataItem.directorateSymbol")%>' width="100%"> </asp:Label> </ItemTemplate> <EditItemTemplate> <asp:DropDownList runat="server" id="ddlDirectorate" CssClass="label" Width="100%" DataSource='<%# GetDirectorateList()%>' SelectedIndex='<%# GetSelectedDirectorate(DataBinder.Eval(Container, "DataItem.directorateID").ToString())%>' DataTextField="directorateSymbol" DataValueField="directorateID"> </asp:DropDownList> </EditItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Division" ControlStyle-Width="100px"> <ItemTemplate> <asp:Label runat="server" ID="lblDivision" Text='<%# DataBinder.Eval(Container, "DataItem.officeSymbol")%>' width="100%"> </asp:Label> </ItemTemplate> <EditItemTemplate> <asp:DropDownList runat="server" id="ddlDivision" CssClass="label" Width="100%" DataSource='<%# GetDivisionList()%>' SelectedIndex='<%# GetSelectedDivision(DataBinder.Eval(Container, "DataItem.divisionID").ToString())%>' DataTextField="officeSymbol" DataValueField="divisionID"> </asp:DropDownList> </EditItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Start Date
<ItemTemplate> <asp:Label runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.dateStartText")%>' ID="lblGridDateStart"> </asp:Label> </ItemTemplate> <EditItemTemplate> <asp:TextBox runat="server" ID="txtGridDateStart" CssClass="label" Width="100%" Text='<%# DataBinder.Eval(Container, "DataItem.dateStartText")%>'> </asp:TextBox> </EditItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="End Date
<ItemTemplate> <asp:Label runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.dateEndText")%>' ID="lblGridDateEnd"> </asp:Label> </ItemTemplate> <EditItemTemplate> <asp:TextBox runat="server" ID="txtGridDateEnd" CssClass="label" Width="100%" Text='<%# DataBinder.Eval(Container, "DataItem.dateEndText")%>'> </asp:TextBox> </EditItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Current Position"> <ItemTemplate> <asp:CheckBox ID="chkbxPositionCurrentDisplay" runat="server" Checked='<%# DataBinder.Eval(Container, "DataItem.positionCurrent")%>' Enabled="false" /> </ItemTemplate> <EditItemTemplate> <asp:CheckBox ID="chkbxPositionCurrent" runat="server" Checked='<%# DataBinder.Eval(Container, "DataItem.positionCurrent")%>' /> </EditItemTemplate> </asp:TemplateField> <asp:CommandField ShowEditButton="True" CancelImageUrl="~/images/cancel.gif" ShowDeleteButton="True" DeleteImageUrl="~/images/delete.gif" EditImageUrl="~/images/edit.gif" UpdateImageUrl="~/images/save.gif" ButtonType="Image" /> </Columns> </asp:GridView>

The code I listed above us on a Web User Control called by another Web User Control which is called by a Web Form. I recreated the Gridview on a new page this morning with all the code behind and it worked.

So I am wondering if this has to do with when the Page_Load get called for each control. I would really like to get it to work on the control.


Could this be a symptom the cause of work item 640?

Wednesday, March 21, 2012

Problem loading saved data back into dropdownlist

I'm completely new to ASP.NET and Ajax, having quickly inherited a project from a consultant who is no longer with us.

Have a form with C# codebehind, and all this is running inside some Ajax components (tabcontainer and update panels). One dropdownlist (SystemID) determines the filtered values in a second dropdownlist (TypeID). In the page, there's the following to determine the source for each list:

<asp:SqlDataSourceID="sqlSystem"runat="server"

SelectCommand="Select Distinct '0' As SystemID, '(Select)' As Description From CMSSystem UNION

Select SystemID,Description From CMSSystem Where Active='1'">

</asp:SqlDataSource>

<asp:SqlDataSourceID="sqlType"runat="server"

SelectCommand="Select Distinct '0' As TypeID, '(Select)' As Description From CMSType UNION

Select TypeID, Description from CMSType Where SystemID = @dotnet.itags.org.SystemID">

<SelectParameters>

<asp:ControlParameterControlID="cboSystem"Name="SystemID"PropertyName="SelectedValue"/>

</SelectParameters>

</asp:SqlDataSource>

When I complete an empty form, the linking between the lists is fine. Select a value from SystemID, then I can select a value from TypeID that has been filtered.

The problem is on trying to load existing data. I have a procedure call inside Page_Load that loads existing values onto the form. Text boxes and checkboxes are just fine, and standalone dropdownlists are fine. I can load SystemID from a dataset row, but when I try to do the same for TypeID (trying to lookup the saved value in the list of filtered items), I find that the items collection is completely empty - and therefore, I get a null selectedvalue. What I'm guessing is that the SqlDataSource isn't "firing" (?) for the TypeID for some reason at the time of Page_Load, so I have no data to bind to the control.

Is that a good assumption, and if so, how can I get around this? I've been floundering around for a couple of weeks with this, and need any assistance I can get.

How about using the Page's Prerender event for that, instead of Load? Alternatively, you could handle theSqlDataSource's Selected event.


Didn't see any change with Page_PreRender instead of Page_Load.

I have this hunch that the SqlDataSource isn't being re-evaluated when I manually set the first dropdownlist's SelectedIndex (based on the previously saved, now retrieved, data). It must be a matter of timing or something. Trying to execute this codebehind:

if (dsRequestDetails.Tables[0].Rows[0]["SystemID"].ToString() !="")

{

liFind = cboSystem.Items.FindByValue(dsRequestDetails.Tables[0].Rows[0]["SystemID"].ToString());

cboSystem.SelectedIndex = cboSystem.Items.IndexOf(liFind);

}

if (dsRequestDetails.Tables[0].Rows[0]["TypeID"].ToString() !="")

{

liFind = cboType.Items.FindByValue(dsRequestDetails.Tables[0].Rows[0]["TypeID"].ToString());

cboType.SelectedIndex = cboType.Items.IndexOf(liFind);

}


populate the second dropdown at the ondatabound event of the first drop down. This will solve your problem