TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
sonal thosar
NA
18
52k
Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index : ListView
Sep 27 2011 5:45 AM
Hi EveryoNE
I have getting
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
<div class="new-cont">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<asp:ListView ID="lstRecentCompanyAnnouncement" runat="server" DataKeyNames="PublishDate"
OnItemDataBound="lstRecentCompanyAnnouncement_ItemDataBound">
<LayoutTemplate>
<tr id="itemplaceholder" runat="server">
</tr>
</LayoutTemplate>
<ItemTemplate>
<tr id="trDate" runat="server" visible="false">
</tr>
<tr>
<td style="padding: 8px;">
<asp:Label ID="lblCompanyAnn" runat="server"><a id="hlVideoURL" runat="server" target="_blank"
href='<%#String.Format("http://bseindia.com/stockinfo/anncomp.aspx?scripcode={0}", Eval("BSECode"))%>'>
<span class="orange">
<%#Eval("CoName") %></span>- <asp:Label ID="lblNamenDesignation" runat="server"
Text=""></asp:Label>
</a>
<asp:HiddenField ID="hdnDescription" runat="server"
Value='<%#Eval("Name") %>' />
<asp:HiddenField ID="hdnNamenDesignation" runat="server" Value='<%#Eval("paramValue") %>' />
</asp:Label>
</td>
<td><span><%#Eval("PublishDate", "{0:hh:mm tt}")%></span></td>
</tr>
</ItemTemplate>
</asp:ListView>
</table>
<asp:DataPager ID="dpCompAnnouncement" runat="server"
PagedControlID="lstRecentCompanyAnnouncement" PageSize="10"
onprerender="dpCompAnnouncement_PreRender">
<Fields>
<asp:NextPreviousPagerField ShowFirstPageButton="True" ShowNextPageButton="False" />
<asp:NumericPagerField />
<asp:NextPreviousPagerField ShowLastPageButton="True" ShowPreviousPageButton="False" />
</Fields>
</asp:DataPager>
</div>
private string prevEventDateAnnouncement = "00 xxx 0000";
protected void lstRecentCompanyAnnouncement_ItemDataBound(object sender, ListViewItemEventArgs e)
{
//try
//{
if (e.Item.ItemType == ListViewItemType.DataItem)
{
ListViewDataItem item = (ListViewDataItem)e.Item;
string AnnouncementDate = string.Empty;
AnnouncementDate = Convert.ToDateTime(lstRecentCompanyAnnouncement.DataKeys[item.DataItemIndex]["PublishDate"]).ToString("dd MMM yyyy");
if (!prevEventDateAnnouncement.Equals(AnnouncementDate, StringComparison.CurrentCultureIgnoreCase))
{
HtmlTableRow trDate = (HtmlTableRow)e.Item.FindControl("trDate");
HtmlTableCell htc = new HtmlTableCell();
htc.ColSpan = 2;
htc.Attributes.Add("class", "date-hd");
htc.InnerHtml = "<b>" + AnnouncementDate + "</b>";
trDate.Controls.Add((HtmlTableCell)htc);
trDate.Visible = true;
prevEventDateAnnouncement = AnnouncementDate;
}
HiddenField hdNamenDesignation = (HiddenField)e.Item.FindControl("hdnNamenDesignation");
HiddenField hdDescription = (HiddenField)e.Item.FindControl("hdnDescription");
Label lblNamenDesignation = (Label)e.Item.FindControl("lblNamenDesignation");
Label lblCompanyAnn = (Label)e.Item.FindControl("lblCompanyAnn");
if (!string.IsNullOrEmpty(hdNamenDesignation.Value))
{
lblNamenDesignation.Text = hdNamenDesignation.Value;
lblCompanyAnn.Attributes.Add("onmouseover", "javascript:tooltip.show('" + hdDescription.Value.Replace("'", "") + "');");
lblCompanyAnn.Attributes.Add("onmouseout", "javascript:tooltip.hide();");
}
else
{
if (hdDescription.Value.Length > 31)
{
lblNamenDesignation.Text = hdDescription.Value.Substring(0, 30) + "...";
lblCompanyAnn.Attributes.Add("onmouseover", "javascript:tooltip.show('" + hdDescription.Value.Replace("'", "") + "');");
lblCompanyAnn.Attributes.Add("onmouseout", "javascript:tooltip.hide();");
}
}
}
//}
//catch (Exception err)
//{
// Response.Write(err.Message);
//}
}
#endregion
protected void dpCompAnnouncement_PreRender(object sender, EventArgs e)
{
lstComAnn();
}
public void lstComAnn()
{
object[] param = new object[2];
param[0] = "HomePageAnnouncement";
param[1] = DBNull.Value;
lstRecentCompanyAnnouncement.DataSource = objHandler.ExecuteProcedureRtnDT("RB_CompanyAnnouncement", param);
lstRecentCompanyAnnouncement.DataBind();
}
Reply
Answers (
6
)
Convert VB.NET Code to C#
How to get local system temp path in ASP.Net