ASP.NET

Moderators: None (Apply to moderate this forum)
Number of threads: 1727
Number of posts: 3292

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
A problem with binding method with event Posted by viettrung on 22 Jun 2003 at 10:59 PM
Hi,

I have a problem with C# Web form programing.

I have tried to create a two-level menu using DataList controls. To do this, I have two DataList controls. The first one (first level) named lstProviders, contains a list of provider names, the second one (second level) named lstCategories, contains a list of product categories which is associated with the selected provider.

The second datalist has been embeded into the <SelectedItemTemplate> of the first one (in .ASPX file). To display a category list corresponding to a selected provider, in .CS file, I did:

- Declare a protected variable in DataList type:
protected System.Web.UI.WebControls.DataList lstCategories;

- Write some code in the SelectedIndexChanged method of the lstProviders as following:

private void lstProviders_SelectedIndexChanged(object sender, System.EventArgs e)
{
//Determine the lstCategories embeded into the selected item of lstProviders
this.lstCategories = (DataList)this.lstProviders.SelectedItem.FindControl("lstCategories");
if (lstKind != null)
{

//Create a new event corresponding to the SelectedIndexChanged of the lstCategories
this.lstCategories.SelectedIndexChanged += new
System.EventHandler(this.lstCategories_SelectedIndexChanged);

lstCategories.SelectedIndex = 0;

// A procedure to bind data to lstCategories lstCategories_Refresh(lstProviders.DataKeys[lstProviders.SelectedIndex].ToString());
}

private void lstCategories_SelectedIndexChanged(object sender, System.EventArgs e)
{

//Some simple code. Label is a Label control declared above.
Label.Text = lstCategories.DataKeys[lstCategories.SelectedIndex].ToString();

}

The method SelectedIndexChanged of lstProviders goes well (that means, can display the category list corresponding to some selected provider), but the one of lstCategories has no reaction.

Can you help me ?

Thanks in advance.

VietTrung.




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.