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
Shaksham Singh
NA
17
6.1k
Find Repeater control in a function
Apr 30 2018 4:51 AM
Hello all, I am trying to bind my anchor tag from database value which is inside my repeater.
here is my repeater :
<
div
class
=
"popular_deals"
>
<
div
class
=
"head"
>
<
div
class
=
"popular_deals_heading"
>
Popular Deals
</
div
>
<
div
class
=
"item"
>
<
asp:Repeater
ID
=
"rptdealsbanner"
runat
=
"server"
OnItemDataBound
=
"rptdealsbanner_ItemDataBound"
>
<
HeaderTemplate
>
<
ul
id
=
"autoplay"
class
=
"content-slider"
>
</
HeaderTemplate
>
<
ItemTemplate
>
<
li
id
=
"mylist"
>
<
a
target
=
"_blank"
id
=
"bannerAnchor"
>
<
img
src
=
'<%#"PopularDeals/"+ Eval("BannerName") %>'
alt
=
'<%# Eval("BannerName") %>'
/>
</
a
>
<
%--
<
asp:ImageButton
ID
=
"imgBanner"
runat
=
"server"
alt
=
"Banner Image"
>
</
asp:ImageButton
>
<
asp:HiddenField
ID
=
"hdnBannerName"
runat
=
"server"
Value
=
'<%# Bind("BannerName") %>'
/>
<
asp:HiddenField
ID
=
"lblurl"
runat
=
"server"
Value
=
'<%# Bind("BannerURL") %>'
>
</
asp:HiddenField
>
--%
>
</
li
>
</
ItemTemplate
>
<
FooterTemplate
>
</
ul
>
</
FooterTemplate
>
</
asp:Repeater
>
</
div
>
</
div
>
</
div
>
My code behind:
private
void
GetDealsBanner()
{
try
{
BLPopularDeals objPD =
new
BLPopularDeals();
DataSet ds = objPD.GetDealsBanner(CountryFromCookies);
if
(ds.Tables[0].Rows.Count > 0)
{
for
(
int
i=0;i<ds.Tables[0].Rows.Count;i++)
{
HtmlAnchor a1 = (HtmlAnchor)rptdealsbanner.FindControl(
"mylist"
).FindControl(
"bannerAnchor"
);
//here i am getting null error ... how do i find my anchor tag and bind data ??
a1.HRef = ds.Tables[0].Rows[i][
"BannerURL"
].ToString() !=
null
? ds.Tables[0].Rows[i][
"BannerURL"
].ToString()
:
"#"
;
}
rptdealsbanner.DataSource = ds.Tables[0];
rptdealsbanner.DataBind();
}
}
catch
(Exception ex)
{
new
TicketingError().Error(ex,
"Default1.aspx---- GetDealsBanner()"
);
}
}
Anybody help me out
Reply
Answers (
1
)
passing data from controller to view is showing NAN value
What is the best tool for conflict merging in GitHub?