Web Hosting Talk







View Full Version : [asp.net c#] chose default value for dropdown menu with a datasource


HardLayers
04-07-2010, 07:18 AM
Hello every one,
I'll try to explain my situation by an example easy to understand

let's imagine a project, that has users and usergroups.

each user has to come be from a usergroup

you have a page to view and add usergroups
you have another page to view and add users (users.aspx?groupid=5)


in the usergroups page. you have a list of groups and beside each group there is the number of users in that group and a link to add a new user to that group. that link refers to the users page which already has a form to add a user with a field (drop down list that has group names in it)

Now let's talk technical


if you come to the user page directly, you will have to chose a group from the list

but if you come from the groups page by clicking on the add a user to this group link


you want that form to select the group name you came from as a default value, and maybe let that dropdown menu (enabled=false)




that drop down menu is an item in a details view that is coming from the usersConnection data source

the menu is a template item with a special datasouce groupsConn

the SELECTED value of that drop down menu is binded to the group_id attribute of the user table.



how can you make do that with the dropdown menu template item?

HardLayers
04-10-2010, 03:00 AM
please ?

Ryan F
04-12-2010, 11:57 PM
please ?

I don't think you can do all that with a datasource. Datasources are for dealing with simple data scenarios. What you’re describing is more complex. You would have to code the logic and populate the dropdown control in the codebehind class. What you're describing (if I understand it correctly) doesn't sound that hard but I wouldn't try to make it happen with a datasource control.