Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 Results from a GridView DropDownList.

Author  Topic 

davidshq
Posting Yak Master

119 Posts

Posted - 2006-05-20 : 16:59:40
I have a GridView and for each row of data there is bound a DropDownList, using a TemplateField. This DropDownList has three responses available - "Accept", "Reject", and "Completed". I need to get the selected value for each row when a user clicks "Apply Responses." Here is my current non-functional code:
Dim row As GridViewRow
Dim droplist As DropDownList = CType(FindControl("DropDownList1"), DropDownList)
For Each row In GridView1.Rows
If droplist.SelectedItem.Value = 1 Then
SqlDataSource1.InsertParameters("varStatus").DefaultValue = 2
SqlDataSource1.InsertParameters("varUser").DefaultValue = Profile.UserName
End If
This is only the first item, but if I can get the first to work, its just a matter of changing the "varStatus" values for the other two.
David.

- http://www.gamesecretary.com/
- http://www.thehungersite.com/
- http://www.grid.org/

dfiala
Posting Yak Master

116 Posts

Posted - 2006-05-20 : 21:00:32
Where are you trying to do this in your code?
What is the error or problem? Are the values just not there or are they reset to the original values?
If they are reset, it is likely you are rebinding your grid before this code is called. Don't bind it on the post back and you should be fine.

In the page load event (which gets called before any other event handlers) do something like....

If Not IsPostBack Then
'Grid fillling code
End if


Dean Fiala
Very Practical Software, Inc
Now with Blogging...
http://www.vpsw.com/blogbaby
Microsoft MVP
Go to Top of Page
   

- Advertisement -