Click here to Skip to main content
15,889,889 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello my requirement is that
database 2 tables
--------------------
1)catagory(catid,category_name)
2)subcatagory(subid,subcategory_name,catid)
i have two dtalist one inside other.
datalist1 will dispaly catagoryname .To display catagoryname i have taken link button
the 2nd datalist will show subctagory on click of each linkbutton on seleted index change
my code is
---------------------
C#
DataListItem item = DataList1.SelectedItem;
       foreach (DataListItem ctitem in DataList1.Items)
       {
           ctitem.FindControl("DataList2").Visible = false;
       }
       SqlDataSource2.SelectParameters[0].DefaultValue = DataList1.DataKeyField[0].ToString();
       DataList1.SelectedItem.FindControl("DataList2").Visible = true;

--------------------------------
problem is that its not coming inside this loop every time i click on link button the refresh take place

Can anyone help me about this
Posted
Updated 8-Jul-12 19:27pm
v3
Comments
Ganesan Senthilvel 7-Jul-12 9:00am    
Code format

1 solution

Hi,
I think you can achieve this using an update panel.
or else you need store the selectedindex value or the DataList1.selectedindex in a viewstate or a hidden variable

if(viewstate["SelectedIndex"] != null)
{
rebuild the datalist 1 and 2 here
}

Thanks
Buy Lace
 
Share this answer
 
Comments
Nagy Vilmos 7-Jul-12 15:16pm    
I for the spam link.
akee seth 8-Jul-12 15:17pm    
ok,i will try this .
thank you

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900