Free Jobs

Dot Net Forums: ASPNET (77) C#.NET (39) VB.NET (8) AJAX (21) Silver Light (1) WCF (10) WPF (1) WWF (1) .NET 3.5 (3) SQL SERVER (38) Other (3)

Topic: How to find DataList ItemId in CodeBehind in OnItemCommand event

To get the Posted Questions details daily in your mail Click Here

Share this Post on Facebook/Twitter/Orkut Bookmark and Share

User: dhiraj5079 Post Date: 07 Jun 2011 07:07

Many a times you need to find out DataList ItemId in CodeBehind in OnItemCommand event

Main Content:

 <asp:DataList ID="DataList1" runat="server" OnItemCommand="DataList1_OnItemCommand" RepeatDirection="Horizontal"  RepeatColumns="3"

ItemStyle-HorizontalAlign="Center" ItemStyle-VerticalAlign="Top" ItemStyle-Width="70">



          <asp:Label ID="Labelid" runat="server" Text=''<%# Eval("id") %>'' Visible="false"></asp:Label>

          <asp:LinkButton ID="LinkButtonRight" runat="server" Text=''<%# Eval("Name") %>'' Font-Underline="false"  ></asp:LinkButton>





protected void DataList1_OnItemCommand(object sender, DataListCommandEventArgs e)


        Label DDLC = (Label)(DataList1.Items[e.Item.ItemIndex].FindControl("Labelid"));


        string id = DDLC.Text;



This way we can find DataList ItemId in CodeBehind in OnItemCommand event

About Writer:
Hi,I am IT Professional From Mumbai

Writer's Link: http://

Writer's Email:

Post Comment

Similar Articles Top ArticlesLatest Articles Other Articles by this Author Copyright © 2009-2011 | All Rights Reserved
All content of this website is protected by copyright laws and should not be reproduced in any form or by any means without written permission
(Best viewed in IE 8.0+ or Firefox 3.0+ at resolution of 1024 * 768 or higher)