GridView EditItemTemplate with DropDownLists

Posted by Rajendra.prasad under ASP.NET on 3/7/2011 | Points: 10 | Views : 4194 | Status : [Member] | Replies : 2
Hi All,
In Admin, while modifying Countries, States, Cities & Locations using GridView in ASP.Net, how to modify Cities category??

DB Tables:-
==========
Countries:
ID: int, not null, Primary Key
Name: varchar(50), not null
IsActive: bit, not null
Priority: int, not null

States:
ID: int, not null, Primary Key
CountryID: int, not null, Foreign Key (Countries -> ID)
Name: varchar(50), not null
IsActive: bit, not null
Priority: int, not null

Cities:
ID: int, not null, Primary Key
StateID: int, not null, Foreign Key (States -> ID)
Name: varchar(50), not null
IsActive: bit, not null
Priority: int, not null

Now the problem is, while trying to modify Cities Category using GridView, Countries to be populated in dropdownlist with data from Countries table and States to be populated in dropdownlist with data from States table and CityName value in text box. so when trying to modify one city, in edit mode - country, state and city with appropriate db values and country & state in dropdownlist with appropriate and other db values but, when country value is changed, state dropdownlist must also changed with appropriate selected value in county dropdownlist.

please help me...

Regards,
Rajendra Prasad




Responses

Posted by: SheoNarayan on: 3/7/2011 [Administrator] HonoraryPlatinum | Points: 25

Up
0
Down
Hi Rajendra,

This may be becoming too complex to do this inside the GridView edit template because of depth and even bubbling, the easier way would be populate div and popup using jQuery or simple JavaScript. You can read http://www.dotnetfunda.com/articles/article970-aspnet-gridview--jquery-ui-tips-and-tricks--part-1-.aspx article to get some idea.

The simplest way of doing this would be redirect to another page with the record id to edit and populate the data in the form and do it.

Thanks

Regards,
Sheo Narayan
http://www.dotnetfunda.com

Rajendra.prasad, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Madhu.b.rokkam on: 3/7/2011 [Member] [MVP] Bronze | Points: 25

Up
0
Down
Using Ajax will simplify to some extent.. To fetch data from database after every selection of dropdown.

Thanks and Regards
Madhu

Rajendra.prasad, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response