开发者

ASP.Net GridView with Dropdown List

开发者 https://www.devze.com 2023-01-14 22:20 出处:网络
As my previous question didn\'t seem to have much popular开发者_如何学运维ity, I decided to change completely the way I approached the problem. Now my issue is that I still have TABLE1 with a foreign

As my previous question didn't seem to have much popular开发者_如何学运维ity, I decided to change completely the way I approached the problem. Now my issue is that I still have TABLE1 with a foreign key FK, but what I want to do now is have the FK column in the GridView display Dropdown Lists. The Dropdown Lists should have their Text property bound to FK in TABLE1 but they should be populated by the different values of FK (stored in TABLE2).

Any idea about how to achieve this ?

PS : Really new to data controls in ASP.Net


1.Bring your Child table and parent table from database as Dataset
2.Assign the dataset as datasource for gridview (parent table (Dataset.Table["ParentTable"]))
3.Add your drop down in edit item template of grid view
4.While Selecting Dropdown identify the values of Dropdown & Query the Child table with selected value.
5.populate the detail in other field.
please use script manager & Update panel while doing this. that would be help full for you.


Create two SQL datasources, one for the parent table and one for the child table. Bind the gridview to the first one and the dropdown in the template to the second one. That should do the trick.

0

精彩评论

暂无评论...
验证码 换一张
取 消