Showing posts with label php. Show all posts
Showing posts with label php. Show all posts

Thursday, March 29, 2012

passing values

hi guys, hello :) im new to asp.net and come from php "gasp" - anyway, i have a list of car categories and when i click an item i want it to populate the datalist with the data, ie - if you click Car1 = select * from Car1.

I already have a search facility, which calls a stored procedure which loads the data by part number. but im not sure how to do this.

the categories are in the same form, so once a category is clicked it loads the data into the same formI'm not sure I follow what the issue is... Having a button postback? Generating the results? Displaying the results?
Hi curt sorry if i confused you

basically i have this function set up

sub loaddata(s as object, e as evenargs)
dim cmd as new sqldataadapter("select * from varCategory", objConn)
objDA.Fill(objDS, "parts")
dgData.Datasource= objDS
dgData.Databind()
objconn.close()

ok now on my form i have a list of cars, and what i want it to do is call this procedure when a car is clicked, and pass on the value of that car to varCategory.

how can i do this?

Hi!

You could call it like this:

Try
cmd =New SqlCommand("usp_TrackUser", objConn)
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.Clear()
cmd.Parameters.Add("@.varCategory", varCategory)
If objConn.State <> ConnectionState.OpenThen objConn.Open()
'execute or asggin to adpater
cmd.ExecuteNonQuery()
Catch exAs System.Exception
'show the error
EndTry

Review the next article:Call a parameterized SP in SQL

Saludos,


What is this "list"? Dropdown? Grid? Etc?

Most controls have an event you can tie to (Click, etc) you can also usually set the control to "autopostback" and allow this event to cause the page to post....

Saturday, March 24, 2012

Passing variables between files

Hey All :)

Im new to asp.net, but come from a background of php so all my asp is in C#.

Now i have a ASP.NET cms system that i am currently making changes to. Now what i have is filename.aspx which up the top calls header.aspx, and i am trying to pass a string from filename.aspx.cs to header.aspx.cs (the name of the header graphic i want to set).


In php i would just set the variable, and in the header file i would call the variable in via global $varName; but in asp this doesnt seem to be working (go figure :p)

Hope it makes sense, all feedback appreciated.

1. you can pass it through the QueryString -

perhaps while you redirect to header.aspx do something like response.redirect("header.aspx?imgfile=" + theVariableHoldingName);
and in the header.aspx.cs do something like (in the Page_Load): string nameOfImage = Rquest.QueryString("imgfile");

2. you can use Session also:

in filename.aspx - Session.Add("imgfile",theVariableHoldingName);
and in header.aspx - string nameOfImage = Session["imgfile"];


ben14:

In php i would just set the variable,

just set the session object where you would set the variable as.. Session["myData"] = value

ben14:

and in the header file i would call the variable in via global $varName

and get the value of that session object where you would call the variable in via global $varName as... myValue = Session["myData"]

dont forget to cast the value... as Session returns an Object..

hope it helps./.


thanks for that :) should work fine.

cheers