Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Column Values to textbox

Status
Not open for further replies.

Bubsa

MIS
Mar 16, 2010
14
GB
I am hoping this is not a silly question but I have been struggling to find an answer. I have created a web application to insert data into SQL database using T_SQL and stored procedures as I needed to update several tables at the same time. The design of a particular page is using text boxes and dropdown list’s and not the default gridviews or details view as I wanted the page structure set out in a particular way.

Anyways I now want to create an update page which I will get redirected to from a search page.

My question is how do I assign the column values to text boxes or Dropdown lists from my Select statement. I was thinking of having a event in the page load method. Sort of like this ‘Select InvoiceID, Invoicetype, Notes FROM TblInvoice Where Invoicenumber = @Invoicenumber “ the parameter value @Invoicenumber will be assigned via the search page so I will also need to pull that in on the page load event.

So my page would look something like this if say the:-

Textbox1 = InvoiceID(Value) DropDownnlist1 = Invoicetype(Value)
Textbox2 = Notes(Value)

Can someone show me how to write this in a code behind page. I would then click a button to update the values if I changed them and write my update statement for the button click event which I know how to do .........Any ideas on the above would be gratefully received.
 
You would pass the InvoiceNumber to the update page in a querystring variable.
Then use that in your select. Select into a datatable. I am assuming you will only be getting one row back?

Then you can set your values
textbox1 = dt.items(0)(0)
textbox2 = dt.items(0)(1)
dropdownlist1.findbyvalue(dt.items(0)(3)).selected = true

something like that. The order may change based on the order you return your columns in

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top