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....

0 comments:

Post a Comment