C
C#15mo ago
ishaan

❔ ASP.NET Web Forms - Populating Labels using Primary key from Dropdown

Hi, using ASP.NET C# to build a webform. How do I populate a label with values from a SQL query (i'm getting a primary key from a dropdown list) This is in WebForms https://pastebin.com/aQPQDntn This is what I have for the source. I cant find anything online about some specific line that is needed to get the data from a query for a primary key. What I mean by this is I have a dropdown which contains my primary keys. And when I select one of those keys, it should populate the labels appropriately.
Pastebin
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
2 Replies
JakenVeina
JakenVeina15mo ago
so, you need an on-change event handler for when the dropdown with the PK changes you can have that trigger a re-post of the form, where your form code on the server will then have the PK and can use it to do whatever, when rendering the new page or you can embed JavaScript in the form that will make ajax requests to an endpoint on your server that you need to add, which will retrieve the label values you want, then more JS code to plop them into the DOM
Accord
Accord15mo ago
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.