Im currently working on a gridview built using Itemplate at runtime.

When in edit mode I use dropdownlists for some of the control fields which are populated from views in my db. The problem I am finding is I usually have a memberID field and a MemberName field and need them to be insync. If the user selects a different ID I need the dropdown with the IDname to move to the corresponding option and vice versa.

Is there a way to do this in a dynamically created gridview. I have seen a few examples using ajax in a gridview built using just the control with a sqldatasource but nothing when the grid is built at runtime.

Recommended Answers

All 2 Replies

Are the indexes the same for both fields? IE is the member number in item#5 also the members name in the other dropdownlist as item #5?

The indexes are maintained so they line up in the drop down lists.

I was thinking about using the selectedindexchanged event handler, now that I set autopostback to true it is firing right away and not waiting for submit.

The problem with handling it this way though is since I am creating the template in a seperate class not in code behind I am having problems figuring out how to access the actuall gridview as it is out of focus and their is no row access in eventargs.

I tried accessing through control(sender) but the gridview cells are null so I am not sure if there is a way to pull the row in the eventhandler when it is not in the code behind.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.