Sunday, March 11, 2012

Looking for compleate working sample of CascadingDropDowns and database

Are you using an UpdatePanel? Make sure you have EnableEventValidation="false" set in your page header.

As for a complete example, you've got half of it right there. The rest of it is at

http://atlas.asp.net/atlastoolkit/Walkthrough/CCDWithDB.aspx


Until now the controls are not used inside an Update Panel. Does your question mean I have to use it or not?

I have seen the tutorialhttp://atlas.asp.net/atlastoolkit/Walkthrough/CCDWithDB.aspx before but if I'm right there are still some points missing:

How / when / where can I pass parameters to my stored procs AND use the CascadingDropDown extender (I know how to execute the stored proc and how to pass parameters to it but I have no idea how this works with the CascadingDropDown extender)

Sorry - the UpdatePanel was due to a similar question from another thread.

You can use a PageMethod by omitting the ServicePath parameter. That will cause the extender to make a PageMethod call to a method specified by ServiceMethod.

We don't currently have a good solution for the parameter issue you bring up. Several other people have asked for that as well. Just so I understand, your scenario is that you want to get a list of things for a particular customer ID or something, right?

But here's a bit of a hack you can try. If you have a separate method for each drop down (as in the sample walkthrough), you don't really need the "category" property that's passed to your web service. Can you just stuff your parameter information in there maybe?

We'll add better support for this - I note the built in Atlas extenders that use WebServices also have this shortcoming, so I'll add an issue for them as well.


sburke_msft:

We don't currently have a good solution for the parameter issue you bring up. Several other people have asked for that as well. Just so I understand, your scenario is that you want to get a list of things for a particular customer ID or something, right?

We'll add better support for this - I note the built in Atlas extenders that use WebServices also have this shortcoming, so I'll add an issue for them as well.

I my case I have a SQL Server stored proc for each DropDown. I need to use a much more complex filter (IN parameters) as just one key. I think the concept of the DataSourceControls would describe the requirements perfect. Sometimes you just execute some SQL to get simple lookup values for your DropDowns and sometimes you need a complex business rule to get your data with a lot of criteria.

So what about thinking for a solution where I can use a DropDownList, bind it to a SQL, XML or ObjectDataSource and extend it then with the CascadingDropDownExtender - This would be perfect!!Big Smile [:D]

Regards,
Dirk


so now I'm trying to build this "easy" sample but still have problems with understanding the Atlas behaviour behinde the scenes:

I have a aspx testpage (in this sample based on a master, but this shouldn't be a problem)

<%

@.PageLanguage="C#"MasterPageFile="~/Master/NetqMasterPagePortal.master"AutoEventWireup="true"CodeFile="Test.aspx.cs"Inherits="Reports_Test"Title="Untitled Page" %>

<%

@.MasterTypevirtualpath="~/Master/NetqMasterPagePortal.master" %>

<

asp:ContentID="Content3"ContentPlaceHolderID="ContentMain"Runat="Server">
<atlas:ScriptManagerProxyID="ScriptManagerProxy"runat="server">
</atlas:ScriptManagerProxy> <atlas:UpdatePanelID="UpdatePanel1"runat="server">
<ContentTemplate>
<asp:DropDownListID="ddlCompanyGroup"runat="server"Width=300px></asp:DropDownList><br/>
<asp:DropDownListID="ddlCompany"runat="server"Width=300px></asp:DropDownList>
<atlasToolkit:CascadingDropDownID="CascadingDropDown1"runat="server"> <atlasToolkit:CascadingDropDownPropertiesTargetControlID="ddlCompanyGroup"
Category="CompanyGroup"
PromptText="Please select a company group"
ServiceMethod="GetCompanyGroups"/> <atlasToolkit:CascadingDropDownPropertiesTargetControlID="ddlCompany"
Category="Company"
PromptText="Please select a company"
ServiceMethod="GetCompanys"
ParentControlID="ddlCompanyGroup"/> </atlasToolkit:CascadingDropDown></ContentTemplate></atlas:UpdatePanel>

</

asp:Content>

Now I like to bind/fill the drop down "ddlCompanyGroup" by adding some entries manualywithout

Websevice
Hi Dirk,

You should change the visibility of your web methods. It can't find them because you marked them asprivate. The rest of it is fine.

Thanks,
Ted

Hi Ted,

Thanks a lot for this hint. After changing the both WebMethods to "public" the first drop down (ddlCompanyGroup) loads now fine.

But the second drop down is still not working. It is disabled until I select a value from the first drop down and then it is enabled. But my service method "GetCompaniesForCompanyGroup" is not executed.

<atlasToolkit:CascadingDropDownID="CascadingDropDown1"runat="server">

<atlasToolkit:CascadingDropDownPropertiesTargetControlID="ddlCompanyGroup"Category="CompanyGroup"PromptText="Please select a company group"ServiceMethod="GetCompanyGroups"/>

<atlasToolkit:CascadingDropDownPropertiesTargetControlID="ddlCompany"Category="Company"PromptText="Please select a company"ServiceMethod="GetCompaniesForCompanyGroup"ParentControlID="ddlCompanyGroup"/>

</atlasToolkit:CascadingDropDown>

How can I get the selected value from the first drop down now passed in the service method of the second drop down? This is not working:

[WebMethod]
public AtlasControlToolkit.CascadingDropDownNameValue[] GetCompaniesForCompanyGroup(string knownCategoryValues,string category)
{
List<CascadingDropDownNameValue> values =newList<CascadingDropDownNameValue>();

values.Add(newCascadingDropDownNameValue("GetCompaniesForCompanyGroup1","1"));
values.Add(newCascadingDropDownNameValue("GetCompaniesForCompanyGroup2","2"));
values.Add(newCascadingDropDownNameValue("GetCompaniesForCompanyGroup3","3"));
values.Add(newCascadingDropDownNameValue("GetCompaniesForCompanyGroup4","4"));

return values.ToArray();
}

Something is missing...

Regards,
Dirk


Hi Dirk,

Try settingEnableEventValidation="false" in yourPagedirective (this is a known issue). It should fix your problem with the second drop down not working. The selected values of all parent drop downs are passed into the web method viaknownCategoryValuesas a string like"CompanyGroup:17;Company:18488;". If you follow the steps in thewalkthroughyou'll see how to easily parse this and retrieve the selected value of any parent drop down.

Thanks,
Ted
Thanks a lot, Ted! SettingEnableEventValidation="false" in myPage directive made both drop downs to work as expected!

No comments:

Post a Comment