Wednesday, March 21, 2012

Pulling values from code behind

In my code behind file I have this function:

1public void getAllSystems()2 {3 MTConnection con = MTConnection.CreateConnection(new Credential(new Context("ClearQuest - Boise","Version 2.0", Micron.Application.Context.Environments.Production),"DSSPROD", Credential.DataSourceTypes.MSSQL, Credential.DataSourceProviders.Odbc));45string sqltest =" select T1.dbid,T12.systemname AS 'ParentSystem',T1.systemname AS 'SupportSystem',T1.systemstate,T1.features,T3.name,T4.stakeholder," +6" T4.fldcolumn_1,T1.systemwebpage,T1.description from ( ( ( ( ( ( ( ( CQ_ADMIN.micronsystem T1 INNER JOIN" +7" CQ_ADMIN.microngroup T6 ON T1.primarysupportgroup = T6.dbid ) INNER JOIN CQ_ADMIN.securitygroups T7 ON T1.secuirtygroup" +8" = T7.dbid ) LEFT OUTER JOIN CQ_ADMIN.parent_child_links T12mm ON T1.dbid = T12mm.child_dbid and 16778862 =" +9" T12mm.child_fielddef_id ) LEFT OUTER JOIN CQ_ADMIN.micronsystem T12 ON T12mm.parent_dbid = T12.dbid )" +10" LEFT OUTER JOIN CQ_ADMIN.parent_child_links T3mm ON T1.dbid = T3mm.parent_dbid and 16804095 =" +11" T3mm.parent_fielddef_id ) LEFT OUTER JOIN CQ_ADMIN.feature_1 T3 ON T3mm.child_dbid = T3.dbid ) LEFT OUTER" +12" JOIN CQ_ADMIN.parent_child_links T4mm ON T3.dbid = T4mm.parent_dbid and 16804263 = T4mm.parent_fielddef_id )" +13" LEFT OUTER JOIN CQ_ADMIN.stakeholder T4 ON T4mm.child_dbid = T4.dbid ) where T1.dbid <> 0 and ((T6.abbreviation =" +14" 'Test ES Eng Software' and T1.systemstate = 'Active')) and ((T7.dbid in (select parent_dbid from" +15" CQ_ADMIN.parent_child_links where parent_fielddef_id = 16778767 and child_dbid in (select child_dbid from" +16" CQ_ADMIN.parent_child_links where parent_fielddef_id = 16777328 and parent_dbid = 33664106)and T12.systemname IS NOT" +17" NULL ))) order by T3.name ASC,T1.systemname ASC";1819 System.Data.DataSet ds = con.ExecuteDataset(CommandType.Text, sqltest);2021foreach (DataRow drCQin ds.Tables[0].Rows)22 {23string parent_system = drCQ["ParentSystem"].ToString();24string child_system = drCQ["SupportSystem"].ToString();25//Response.Write(child_system + "<B><I>'S PARENT IS</I></B> " + parent_system + "<BR />");26 }27 }I would like to pull the values of parent_system and child_system into my main page but I don't know how to do that. Is it even possible?
Thanks,
Xana.

If there are mulitple records returned in your result set, then simply bind your returned DataSet to a GridView. I'm assuming you just want to display you data correct?

|||

No, I just need to pass the two strings, and all of thier values, to the main page. I am trying to construct a JavaScript array based on the two strings but I need to pass all of the values before I can do that. I already know how to use ASP values and variables in JavaScript but I don't know how to pull the value into the main page for use.

|||

How about loading the results into two different HiddenField controls whcih you can then use later from your JavaScript routines.

|||

How would I seperate them out into two hiddenfields.

The reason I ask is that with what I am trying to do each child_system has a parent_system that it belongs too. I would lIke to create an associative array out of the two strings. Plus in total the for each loop that they are in returns 90 + results.

Even if I were to create the array in the code behind ( which I don't know how to do (in C#) ) I would still need to pull the array into the main page.

|||

You can't. I misunderstood what you were wanting to do. I'd have to think about a solution.

|||

Is there any way at all to pull the values into the main page?

|||

Can you at all utilize the ClientScriptManager.RegisterArrayDeclartion method?

http://msdn2.microsoft.com/en-us/library/system.web.ui.clientscriptmanager.registerarraydeclaration.aspx

|||

How exactly would that script help me? And how would I use it exactly. I am looking at it but not really understanding it.

|||

To be honest, I'm not exactly sure. It's just a way to create a JavaScript array from code. The only problem is that the method excepts a string for its ArrayValue field instead of an array of some sort, so creating the parameter itself would be a pain. If I can think of any other ideas, I'll let you know.

|||

If I print out the variables into hidden fields with the names being the parent system and the values being the child system would it be possible to, by using a javascript function, call all of the values of the hidden fields?

An example would be there is a drop down menu with the parent systems. Say the user chose TEST_ESENG_SOFTWARE from the menu. TEST_ESENG_SOFTWARE had three child systems, TEST_ONE, TEST_TWO, TEST_THREE ( not using real names ).

With the onchange event for the first drop down menu I could call the function that gets the values from the hidden form fields that have the name TEST_ESENG_SOFTWARE, and then use them to populate a second drop down menu.

Is the above senerio at all possible?? If it is how would I do it?

|||

That would be tough to do when the number of items in your data would vary. I'm not a JavaScript person by any means so I don't know how you'd extract values from a series of controls. Is your whole purpose for wanting this in JavaScript for performance? If so, might I suggest using an AJAX cascading drop-down list.

|||

The reason for doing this in JavaScript is to avoid using postbacks because clearquest can get quite slow with return large sets of results. I know a method exists that gets the elements it is: getElementsByName() but I do not know exactly how to use it to return the actual values.

Do you know anyone who could help us on this forum? If so please give me a name as I can send them a message. If not, oh well I can try to find something online that can help me more. Your suggestions have been extremely helpful.

|||

I wish I knew someone who could help you more, but I don't. It really sounds like you might benefit from using AJAX. Regardless, good luck.

No comments:

Post a Comment