473,322 Members | 1,566 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

datalist inside a tabcontainer does't shows links

3
hi,
i have a datalist inside a tabcontainer. I need to display data from database into the datalist as hyperlink, and when i click on any of that link it should navigate to another page and to display data according to that link.

i have tried and it works fine when the datalist is not placed inside the tabcontainer, but when i put datalist inside tab container the "OnItemdatabound " event does't fire.
here is the code.
--------------------C# File------------------------------------
Expand|Select|Wrap|Line Numbers
  1. protected void Page_Load(object sender, EventArgs e)
  2.     {
  3.  DataSet myds = new DataSet();
  4.         da.Fill(myds);
  5.         DataList1.DataSource = myds;
  6.         DataList1.DataBind();
  7. }
  8. protected void datalist1(object sender, DataListItemEventArgs e)
  9.     {
  10.         HyperLink hpclk = (HyperLink)(e.Item.FindControl("hlpnews"));
  11.  
  12.         hpclk.NavigateUrl = "~/NewFolder1/main.aspx?Username="+ hpclk.Text;
  13.     }
------------in .aspx file---------------------------------------------------
Expand|Select|Wrap|Line Numbers
  1.   <asp:DataList ID="DataList1" runat="server" BorderColor = "Black" OnItemDataBound="datalist1">
  2.     <ItemTemplate>
  3.                  <asp:HyperLink runat ="server" ID="hlpnews" text='<%#DataBinder.Eval(Container.DataItem,"Username") %>' >
  4.                  </asp:HyperLink>
  5.               </ItemTemplate>
  6.  
  7.            </asp:DataList> 
------------------------------------------------------------------------------
the above code works fine for a datalist outside the tabcontainer, but does't work for 1 inside the container.
any one can help plz,
Feb 14 '10 #1
3 3191
tlhintoq
3,525 Expert 2GB
TIP: When you are writing your question, there is a button on the tool bar that wraps the [code] tags around your copy/pasted code. It helps a bunch. Its the button with a '#' on it. More on tags. They're cool. Check'em out.
Feb 14 '10 #2
sara10
3
can any one help please...why isn't "Onitemdatabound" event firing??..
Feb 15 '10 #3
Frinavale
9,735 Expert Mod 8TB
Hmmm, I'm not 100% on this but I think I know what's wrong.

When a control fires an event it needs to be handled by it's parent container....the parent container in your case may have become the TabContainer and so your Page code will never see it fire. I experienced this a while ago when I was trying to handle the onclick event for LinkButtons in a custom class that implemented the ITemplate interface...the LinkButton's click event was being fired to the class and it was never getting to my page code...so I had to re-raise the event from there.

I don't know why the TabContainer would do this...but it's the only reason I can think of that "might" be causing this problem.

I am going to recommend that you move the code in the DataBound event out of your C# code and instead use the DataBinding syntax to declaratively do this.

For example:
Expand|Select|Wrap|Line Numbers
  1. <asp:DataList ID="DataList1" runat="server" BorderColor = "Black">
  2.   <ItemTemplate>
  3.     <asp:HyperLink runat ="server" 
  4.          ID="hlpnews"
  5.          text='<%#DataBinder.Eval(Container.DataItem,"Username") %>' 
  6.          NavigateUrl='~/NewFolder1/main.aspx?Username=<%#DataBinder.Eval(Container.DataItem,"Username") %>' >
  7.      </asp:HyperLink>
  8.  </ItemTemplate>
  9. </asp:DataList>
I don't know if you can do this with the NavigateUrl property...but give it a try and let me know how things go.

-Frinny
Feb 16 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Arjen | last post by:
Hello, Here is my datalist. <asp:DataList id="myDataList" CellPadding="4" Width="100%" runat="server"> <ItemTemplate> <span class="Normal"> <asp:HyperLink id="link" Text='<%#...
2
by: acko bogicevic | last post by:
Hi I have a problem something like this I want to show in datalist customers but below to show orders for customer. I created datalist control and inside it i have to label for CustomerID and...
1
by: wsyeager36 | last post by:
I have a datagrid inside a datalist. The datalist shows parent info and the datagrid shows the child info for that parent. There is a checkbox on each row of the child datagrid. Also inside the...
0
by: Jim Heavey | last post by:
I am wanting to use the ability to databind a control to a field in a table. In order to do this, I have to use a control like Datagrid or DataList. Given those choices, I choose the DataList. ...
6
by: tshad | last post by:
I need to get to a status label I have on my footer section of my datalist. There is no event happening that would go to the footer. I am just doing some processing and want to update the label...
1
by: AndrewR | last post by:
Hey all, Have a strange one here I don't understand.... I have a DataList control in an .aspx page. Inside the DataList's <ItemTemplate> is a single LinkButton control. On the initial page...
2
by: Laura K | last post by:
I would like to create a nested datalist inside the selecteditemtemplate of a datalist. My hope is that when a user clicks on a link a set of child links is displayed. For example if the user...
1
by: WB | last post by:
Hi, I would like to do something like this page: http://www.stocklayouts.com/Products/Postcard/Postcard-Template-Design-Library.aspx?kwid=38 Notice when you mouse-over any of the icons under...
1
by: mister-Ed | last post by:
I am displaying subcategories in my datalist, and now I have a bizarre thing happen when I add a new subcategory record in my sql database, the new subcategory link does not click into the next...
2
by: =?Utf-8?B?Q29sb3JzdG9uZQ==?= | last post by:
Hi, I have a TabContainer inside a data bound FormView (to logically group the form fields into different tabs). The display part of the data binding works fine, but the Update doesn't. ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.