making progress in trying to get atlas working...But not quite there yet...
To populate the dropdownlists from a database:
Public Function populateProjectDDL()
Dim knownCategoryValues As String
Dim category As String
(...)
(Filled my dataset called ds1.)
For Each datarowitem As DataRow In ds1.Tables(0).Rows
?!?!?!?!
Next
return ?!?!?!
end function
What do I return, how do i fill the whatever i return?
(http://atlas.asp.net/atlastoolkit/Walkthrough/CCDWithDB.aspx[^]
was trying to follow that example but they lost me in the c++)
Please help me?
Made more progress, but [method error 500] in the first drop down list...
Here is my code so far:
File "Webservice.asmx":
<%@.WebServiceLanguage="VB"Class="WebService" %>
Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports AtlasControlToolkit
Imports System.Collections.Generic
Namespace Wells_KM_System
<WebService(Namespace:="http://tempuri.org/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
PublicClass WebService
Inherits System.Web.Services.WebService
Protected ds1As DataSet
Protected dbComponent1AsNew DataBase
<WebMethod()> _
PublicFunction populateProjectDDL(ByVal knownCategoryValuesAsString,ByVal categoryAsString)As CascadingDropDownNameValue()
'Dim knownCategoryValues As String
'Dim category As String
'Which projects to show:
If Session("admin") = 1Then
ds1 = dbComponent1.selectOneCondition("Project","active", 1)
'info1.InnerText = "As admin, you see inactive projects, wells, sections and Drilling units as well."
Else
Dim querystr ="SELECT DISTINCT P.project_id, P.project_name FROM Project as P, UserRole as UR WHERE "
querystr = querystr +"UR.user_id = " & Session("active_user") &" AND "
querystr = querystr +"UR.project_id = P.project_id AND "
querystr = querystr +"P.active = 1"
ds1 = dbComponent1.query(querystr)
EndIf
Dim objTableAs System.Data.DataTable
objTable = ds1.Tables(0)
If ds1.Tables(0).Rows.Count > 0Then'user can set defaults
With objTable
Dim intRowAsInteger
Dim valuesAs List(Of CascadingDropDownNameValue) =New List(Of CascadingDropDownNameValue)
For intRow = 0To .Rows.Count - 1
values.Add(New CascadingDropDownNameValue(.Rows(intRow).Item("project_name").ToString, .Rows(intRow).Item("project_id")))
Next
Return values.ToArray
EndWith
ReturnNew CascadingDropDownNameValue() {}
'Return knownCategoryValues
'Return category
Else
ReturnNothing
EndIf
ds1.Clear()
EndFunction
EndClass
EndNamespace
And the aspx file with the drop downs:
<%@.PageLanguage="VB"AutoEventWireup="false"CodeFile="MyDefaults.aspx.vb"Inherits="Wells_KM_System.Personal_MyDefaults" %>
<%@.RegisterAssembly="AtlasControlToolkit"Namespace="AtlasControlToolkit"TagPrefix="atlasToolkit" %>
<!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<htmlxmlns="http://www.w3.org/1999/xhtml">
<headrunat="server">
<title>Set my defaults</title>
<METAhttp-equiv="Content-Type"content="text/html; charset=windows-1252">
<metacontent="Microsoft Visual Studio .NET 7.1"name="GENERATOR">
<metacontent="Visual Basic .NET 7.1"name="CODE_LANGUAGE">
<metacontent="JavaScript"name="vs_defaultClientScript">
<metacontent="http://schemas.microsoft.com/intellisense/ie5"name="vs_targetSchema">
<LINKhref="../Wells_KM_System_Styles.css"type="text/css"rel="stylesheet">
</head>
<body>
<formid="form1"runat="server">
<div>
<asp:LabelID="Label1"runat="server"CssClass="label"Style="z-index: 100; left: 35px;
position: absolute; top: 156px"Text="Select your default well:"></asp:Label>
<asp:LabelID="Label2"runat="server"CssClass="label"Style="z-index: 101; left: 33px;
position: absolute; top: 96px"Text="Select your default project:"></asp:Label>
<asp:LabelID="Label3"runat="server"CssClass="heading"Style="z-index: 102; left: 35px;
position: absolute; top: 24px"Text="Set your default values:"></asp:Label>
<asp:LabelID="Label4"runat="server"CssClass="label"Height="6px"Style="z-index: 103;
left: 35px; position: absolute; top: 214px"Text="Select your default section:"
Width="161px"></asp:Label>
<asp:LabelID="Label5"runat="server"CssClass="label"Height="1px"Style="z-index: 104;
left: 36px; position: absolute; top: 273px"Text="Select your default drilling unit:"
Width="178px">
</asp:Label>
<asp:DropDownListID="projectDDL"runat="server"CssClass="label"Style="z-index: 105;
left: 281px; position: absolute; top: 92px"AutoPostBack="True"TabIndex="1">
</asp:DropDownList>
<asp:DropDownListID="wellDDL"runat="server"CssClass="label"Style="z-index: 106;
left: 281px; position: absolute; top: 154px"AutoPostBack="True"TabIndex="2">
</asp:DropDownList>
<asp:DropDownListID="sectionDDL"runat="server"CssClass="label"Style="z-index: 107;
left: 281px; position: absolute; top: 214px"TabIndex="3">
</asp:DropDownList>
<asp:DropDownListID="drillingunitDDL"runat="server"CssClass="label"Style="z-index: 108;
left: 282px; position: absolute; top: 271px"TabIndex="4">
</asp:DropDownList>
<asp:ButtonID="Save"runat="server"CssClass="button"Style="z-index: 109; left: 34px;
position: absolute; top: 340px"Text="Save defaults"TabIndex="5"/>
<asp:LabelID="Label6"runat="server"CssClass="normal"Height="3px"Style="z-index: 110;
left: 237px; position: absolute; top: 27px"Text="(These values will be used to automatically set these values when you use the application, but you will still be able to change them)"
Width="325px"></asp:Label>
<divid="info1"runat="server"class="notice"style="display: inline; z-index: 111;
left: 578px; width: 303px; color: red; position: absolute; top: 89px; height: 54px">
</div>
<divid="info2"runat="server"class="notice"style="display: inline; z-index: 112;
left: 178px; width: 200px; color: red; position: absolute; top: 342px; height: 15px">
</div>
<atlas:ScriptManagerid="ScriptManager1"EnablePartialRendering="true"runat="server"></atlas:ScriptManager>
<atlasToolkit:CascadingDropDownID="CascadingDropDown1"
runat="server">
<atlasToolkit:CascadingDropDownProperties
TargetControlID="projectDDL"
Category="Project"
PromptText="Select a project"
ServicePath="WebService.asmx"
ServiceMethod="populateProjectDDL"/>
<atlasToolkit:CascadingDropDownProperties
TargetControlID="wellDDL"
ParentControlID="projectDDL"
PromptText="Select a well"
ServiceMethod="populateWellDDL"
ServicePath="WebService.asmx"
Category="Well"/>
<atlasToolkit:CascadingDropDownProperties
TargetControlID="sectionDDL"
ParentControlID="wellDDL"
PromptText="Select a section"
ServiceMethod="populateSectionDDL"
ServicePath="WebService.asmx"
Category="Section"/>
</atlasToolkit:CascadingDropDown>
</div>
</form>
</body>
</html>
(Only trying to populate the first drop down list for now)
Have you seenFAQ#20?
Hi,
thx for reply, but I tried that (read the faq, searched forum, read a lot of posts: that's how I got that far...)
Sometimes it gives me [Method error 12031] as well in the drop down list. And so far, as I wrote, I'm only trying to get the first drop down to populate... Think I should be good once I get one to work.
Now I'm thinking the WebService.asmx file is not even kicking in: put a breakpoint on the line:
PublicFunction populateProjectDDL(ByVal knownCategoryValuesAsString,ByVal categoryAsString)As CascadingDropDownNameValue()
But it never kicks in...
I would be very gratefull if someone manages to spot what goes wrong, I'm really eager to see this working and have been sweating on this for 4 days now...
Ok!
I watched this:
http://forums.asp.net/thread/1305208.aspx
And I noticed he populated the first one with a PageMethod, and a script on the aspx page.
I tried that and it got my first DDL populated!!! (which resulted in a little cry of joy)
Sorry about the double post, but there's no edit button, and I don't want anyone wasting time here when I solved it!
But I have no idea why this was the way to do it... But it worked...
Moving on to the next drop downs...
Microsoft #1 !!! Developpers!Developpers!Developpers! :P
Moving on to the second drop down:
1. With a breakpoint in the asmx file, it seems it's never kicking in either...
2. How would I get the first drop downs selected value (needed for the sql query for second drop down, in vb of course...)
Complete WebService.asmx:
<%@.WebServiceLanguage="VB"Class="WebService" %>
Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports AtlasControlToolkit
Imports System.Collections.Generic
Namespace Wells_KM_System
<WebService(Namespace:="http://tempuri.org/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
PublicClass WebService
Inherits System.Web.Services.WebService
Protected ds1As DataSet
Protected dbComponent1AsNew DataBase
<WebMethod()> _
PrivateFunction populateWellDDL(ByVal knownCategoryValuesAsString,ByVal categoryAsString)As AtlasControlToolkit.CascadingDropDownNameValue()
'populate:
Dim conditionFAsString() = {"project_id","active"}
Dim conditionVAsString() = {projectDDL.SelectedValue, 1}
ds1 = dbComponent1.selectMultipleCondition("Well", conditionF, conditionV)
If ds1.Tables(0).Rows.Count > 0Then
Dim objTableAs System.Data.DataTable
objTable = ds1.Tables(0)
With objTable
Dim intRowAsInteger
Dim valuesAs List(Of CascadingDropDownNameValue) =New List(Of CascadingDropDownNameValue)
For intRow = 0To .Rows.Count - 1
values.Add(New CascadingDropDownNameValue(.Rows(intRow).Item("well_name").ToString, .Rows(intRow).Item("well_id")))
Next
Return values.ToArray
EndWith
ReturnNew CascadingDropDownNameValue() {}
Else
ReturnNothing
EndIf
ds1.Clear()
EndFunction
EndClass
EndNamespace
<%@.WebServiceLanguage="VB"Class="WebService" %>
Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports AtlasControlToolkit
Imports System.Collections.Generic
Namespace Wells_KM_System
<WebService(Namespace:="http://tempuri.org/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
PublicClass WebService
Inherits System.Web.Services.WebService
Protected ds1As DataSet
Protected dbComponent1AsNew DataBase
<WebMethod()> _
PrivateFunction populateWellDDL(ByVal knownCategoryValuesAsString,ByVal categoryAsString)As AtlasControlToolkit.CascadingDropDownNameValue()
'populate:
Dim conditionFAsString() = {"project_id","active"}
Dim conditionVAsString() = {projectDDL.SelectedValue, 1}
ds1 = dbComponent1.selectMultipleCondition("Well", conditionF, conditionV)
If ds1.Tables(0).Rows.Count > 0Then
Dim objTableAs System.Data.DataTable
objTable = ds1.Tables(0)
With objTable
Dim intRowAsInteger
Dim valuesAs List(Of CascadingDropDownNameValue) =New List(Of CascadingDropDownNameValue)
For intRow = 0To .Rows.Count - 1
values.Add(New CascadingDropDownNameValue(.Rows(intRow).Item("well_name").ToString, .Rows(intRow).Item("well_id")))
Next
Return values.ToArray
EndWith
ReturnNew CascadingDropDownNameValue() {}
Else
ReturnNothing
EndIf
ds1.Clear()
EndFunction
EndClass
EndNamespace
----- In the aspx file:
<asp:DropDownListID="projectDDL"runat="server"CssClass="label"Style="z-index: 105;
left: 281px; position: absolute; top: 92px"AutoPostBack="True"TabIndex="1">
</asp:DropDownList>
<asp:DropDownListID="wellDDL"runat="server"CssClass="label"Style="z-index: 106;
left: 281px; position: absolute; top: 154px"AutoPostBack="True"TabIndex="2">
</asp:DropDownList>
<asp:DropDownListID="sectionDDL"runat="server"CssClass="label"Style="z-index: 107;
left: 281px; position: absolute; top: 214px"TabIndex="3">
</asp:DropDownList>
<atlasToolkit:CascadingDropDownID="CascadingDropDown1"runat="server">
<atlasToolkit:CascadingDropDownProperties
TargetControlID="projectDDL"
Category="Project"
PromptText="Select a project"
ServiceMethod="populateProjectDDLPageMethod"/>
<atlasToolkit:CascadingDropDownProperties
TargetControlID="wellDDL"
ParentControlID="projectDDL"
PromptText="Select a well"
ServiceMethod="populateWellDDL"
ServicePath="WebService.asmx"
Category="Well"/>
<atlasToolkit:CascadingDropDownProperties
TargetControlID="sectionDDL"
ParentControlID="wellDDL"
PromptText="Select a section"
ServiceMethod="populateSectionDDL"
ServicePath="WebService.asmx"
Category="Section"/>
</atlasToolkit:CascadingDropDown>
1. Check that your web.config allows Atlas to use web services (I think there's a special entry in there).
2. Have a look at the AtlasControlToolkit.CascadingDropDown.ParseKnownCategoryValuesString method as used by CarsService.cs. This method returns the selected value of a CDD and all its parents.
My web.config is good...
And I got it working by putting all the populate drop down lists in the aspx file... Seems to work, but it's ugly; would have been nicer with a asmx file.. What I did feels like a workaround (and i would have liked to use that webservice.asmx to populate similar drop downs threw the rest of my project). The end result is still much better than the entire page with tons of controls blinking, which could make a user think the datagrid was being updated at every drop down selection.
I'll still be checking here just in case someone ever spots what's wrong, or if I find out I'll come post the solution (I'm sure someone will find it useful?)
But for now I have to move on, can't stay stuck on the webservice thing too long.
Ok, last (i hope) noob question:
What's the line to get the selected value with VB?
variable = ?
Or to set it...
? = variable
Hi,
Check outhttp://forums.asp.net/thread/1391360.aspx.
Thanks,
Ted
I had a similar problem this weekend, after changing the source code for CCDs I couldn't get any of them to populate, checked all my web service methods, source code numerous times and everything seemed right. Triple checked I had copied all of the web.config settings from the sample web site, but still no joy. Eventually I spotted a new attribute attached the the web service class in the sample app, copied this to my own project and voila everything works again.
This is what needs to be attached to the class that implements your web methods:
C#
[Microsoft.Web.Script.Services.ScriptService()]
VB.NET
<Microsoft.Web.Script.Services.ScriptService()>
This the definition of my class just to show it in context
[WebService(Namespace =http://virtualrealitycycling.com/)]
[WebServiceBinding(ConformsTo =WsiProfiles.BasicProfile1_1)]
[Microsoft.Web.Script.Services.ScriptService()]
publicclassSoftwareService : System.Web.Services.WebService
{
//methods in here
}
No comments:
Post a Comment