Specifically databinding a dropdownlist within a gridview

I have an ASP.NET web form with a gridview being dynamically populated by a datasource. There are three columns in the gridview, the first Column1, is an ID column which is hidden from view (ProgramID). The second, Column2, contains a name, which when in edit mode, converts to a textbox (ProgramName). The third (and the piece I need help with), Column3, lists a Name (SiteName), and when in edit mode, produces a dropdownlist. The selected value of this dropdownlist is bound to the ID of this name (not the name itself - this is SiteID). All of this comes out of the stored proc tied to the select function for the gridview.

Now here is where I need help. Column3, when edited, turns into a drop down list. This drop down list needs to display Site Names and IDs, which are contained in a different stored procedure. So, while the overall gridview is filling from one stored procedure, along with the actual current valuie of Column3, I want the user to be able to edit that 3rd column, and have their list of available choices come from the filling of that dropdownlist from another stored procedure. In less complicated terms, **can you individually bind elements within an edittemplate to stored procedures that are not the primary select procedure**? The IDs that would populate this dropdown list would obviously correspond to the update ID that would go in the update procedure, I dont need to fire a separate stored proc for that.

I see where you are going with this, and I understand why its going to call it on each row. Is there a way to sort of call the fill procedure once, and then repeat the outcome per row? With datasets or something? I'm a bit new to programming this way, so if what I said didnt make sense, let me know.

no, I do not think it will be called for every single row .. its within the edititemtemplate and so will processed and appears only for the row been edited i.e when the "edit" is clicked .. so processed for one row per edit ..
nuvium, you can validate this by putting a breakpoint in GetSites and verify when and how many times the function is called ..

>> Is there a way to sort of call the fill procedure once
Even though the code will be called only for the edit column, this would be called everytime the user clicks on the edit button or when multiple users use the same page.. if you want to optimise the code so that the database is not hit everytime the user opts to edit, you can cache the "SiteList" datatable and read from the cache instead of the database ..

Rejo

0

nuviumAuthor Commented: 2007-10-17

Rejo -

I modified my code per your instrucitons, and so far it LOOKS like its working fine. I am going to test out a few things and make sure its working with my update statement correctly, but I believe you helped solve my problem. And you are right, its only firing that GetSites query on the row thats being updated.

0

Featured Post

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.