Showing posts with label cascasding. Show all posts
Showing posts with label cascasding. Show all posts

Monday, March 26, 2012

Cascasding Drop Down Page method custom variable

Hi

I have page method populating the first of my drop downs and the reason being is that i need a variable that will be specific to user.
Currently this is stored in the session...How can i use this variable in the Page Method that is static...I cant really use a static variable as they are shared between all users.

Thanks.

Steve

Hi Steve,

Unfortunately I don't know of a good way to do this anymore. When we first wrote CascadingDropDown page methods weren't required to be static so there was an easy solution. Could you create a work item on CodePlex for this? Perhaps we could modify the web service signature to include optional tag info.

Thanks,
Ted

AAAAAHHHHH!!!!!

Well i have found a solution that works for me and may well for others.....
I have a web method that has Sessions enabled that i can call to get the value from...of course this method cannot be on the page as Sessions arent static.

[

WebMethod(EnableSession =true)]
publicCascadingDropDownNameValue[] GetDivisionsBySessionIdAccount(string knownCategoryValues,string category)
{
SessionCollection oSC; if (Session["UserObj"] !=null) {
oSC = (SessionCollection)Session["UserObj"];
// Calling another method to get my array - the same one i used from the page method.
CascadingDropDownNameValue[] retArray = GetDivisionsByIdAccount(oSC.idAccount);
return retArray;
}
else {
thrownewException("Your Session Has Expired");
}
}

I have created a work item number7579 for this.

---

I have just updated to the release toolkit and now my CCDD have stopped working! The top drop down loads fine from the method above but none of the others below. I have a debug error in jsSys.Debug is null or not an object.??

ARGH!


Here's more on the typical cause of Sys.Debug is null:http://forums.asp.net/thread/1546990.aspx

Cascasding drop down - Error 500

Hi
I am playing with the cascading drop down control...
i have written a method to get data from sql 05 database and return andarray of CascadingDropDownNameValue. (i watched one of the how towebcasts on it)....anyway, i can get it to work else where but forsome reason its not working with this one.
I know the method is returning the right data as i have another methodwhich returns all values in a string[] i then dump on the screen andall is ok.
My CCD declaration.

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

<atlasT:CascadingDropDownProperties

Category="CategoryName"

ParentControlID="ddlClass"

TargetControlID="ddlCourses"

PromptText="All"ServiceMethod="GetCoursesByIdClass"

ServicePath="webservices/FillDropDowns.asmx"/>

</atlasT:CascadingDropDown>

My method...

[WebMethod]

publicCascadingDropDownNameValue[] GetCoursesByIdClass(string knownCategoryValues,string category)

{

// Get connection string from web.config

string dsn = System.Configuration.ConfigurationManager.ConnectionStrings["connCleo"].ConnectionString;

string[] categoryValues = knownCategoryValues.Split(':',';');

int idClass =Convert.ToInt32(categoryValues[1]);

// SQL script

string sql =@dotnet.itags.org."SELECT c.idCourse, c.chrName FROM cleo.Course c

JOIN cleo.CourseAssign ca ONca.idCourse=c.idCourse

WHERE idClass=@dotnet.itags.org.idClass

ORDER BY c.chrName";

// Generic list for collection

List<CascadingDropDownNameValue> cascadeCollection =newList<CascadingDropDownNameValue>();

// Open connection and execute command...loop through reader and add items to list.

using(SqlConnection conn =newSqlConnection(dsn))

using (SqlCommand cmd =newSqlCommand(sql, conn))

{

cmd.Parameters.AddWithValue("@dotnet.itags.org.idClass", idClass);

conn.Open();

using (SqlDataReader reader = cmd.ExecuteReader())

{

while (reader.Read())

{

cascadeCollection.Add(newCascadingDropDownNameValue(reader.GetString(1), reader[0].ToString()));

}

}

}

// return collection as an array.

return cascadeCollection.ToArray();

}


I dont know of anyway i can debugthis to see if i am infact getting the correct values back(not surewhat values i need to pass to the method to mimic the call from thetoolkit.)?

Hopefully someone can see where i am going wrong.??

Thanks
Steve

OK, so i am pulling my hair out and have no idea where to look for help other than here.

I have put the same code in another project and it works fine.

The only difference that i can see is the version of the Atlas and Toolkit dll.

The date stamp on the one that works is 04/05/2006
The one that doesnt work is 27/06/2006

So begs the question....what has changed in the June CTP that stops my service from working?

Any ideas?
Steve


Again...the brick wall.
I added in the new CTP dll's to my project that works and it still works.

If i add the old dll's into my not working project...i dont get error 500, but i do get a popup error when trying to change the selection of parent ddl...(eventvalidation error) and no, nothing is bound to the Drop down.

:-(

Steve


sorted it!!!!

I was missing stuff from the web.config file !!!

Well thats two hours of my life gone!!!

Steve


OK...new error now. i seem to be speaking to myself here but if anyone does join in maybe they can help.

The drop down is not binding fine...problem is when i try and postback (with button) i get a postback validation error (there are a few posts on here with no clear answer, none regarding the CDD control though)...anyway, so i turn of validation and the value in the second drop down list has nothing...it should be an number (as id for the text on display...nothing odd there).

I have tried

protectedoverridevoid Render(HtmlTextWriter writer)
{
ClientScript.RegisterForEventValidation(this.UniqueID);
base.Render(writer);
}

but this has no affect.

Steve


i was a touch hasty with my previous post...there is a value in the selectedvalue property....however i was checked that selectedindex > 0...even though it was, it wasnt (if that makes sense - the debugger says 0)...however i got round this withstring.IsNullOrEmpty(ddl.SelectedValue)

But now i have to have eventvalidation off.

What are the implications of this...surely this isnt correct? I must be able to have it turned on...not sure what i does but feel like i'm missing out!!!!!!

Anybody?

Steve


Seee http://forums.asp.net/thread/1293293.aspx #20

Event Validation just makes sure the values you posted from your dropdown are valid values you populated it with. But seeing as the cascading dropdown populates from script, this wont/cant work and if you need to, validate the values on the server (its a security thing)