开发者

Pre-select items on data-bound cascading dropdown lists in ASP.NET page

I have the following problem:

On a ASP.NET page, say books.aspx, I have three dropdown lists: ddlBook, ddlChapter, ddlPage, one listview lvPageContents and four sql datasources dsBooks, dsChapters, dsPages and dsPageContents.

On initial design, user selects the Book from ddlBook (populated from dsBook), then Chapter (from the selected book's chapters) and Page (from the selected chapter's pages)开发者_JS百科. Finally, the lvPageContents shows the data of the selected page.

I would like to add the functionality of calling books.aspx with QueryString("BookID") or "ChapterID" or "PageID" and programmatically put the corresponding values as selected items to the corresponding dropdown lists.

Should I completely override the datasource/databinding of ASP.NET in code behind, or is there another workaround?


In code behind .cs file you can pre select Drop down list using Item Lists index.

DropDownList1.SelectedIndex = 0;

or by using values like this-

DropDownList1.SelectedValue = "page1";
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜