Cannot access checkbox checkedchanged event inside DataList - asp.net

I have checkboxes inside a datalist itemtemplate..But i cant access checkbox chechedchange event. I set AutoPostBack as true. But still cant fire event.
Here my codes.
<ul class="commentlist" >
<asp:DataList ID="datalistYorum" runat="server" DataSourceID="ods_yorumlar"
RepeatLayout="Flow" ItemStyle-Wrap="True" RepeatDirection="Horizontal"
onitemcreated="datalistYorum_ItemCreated"
onitemdatabound="datalistYorum_ItemDataBound" onload="datalistYorum_Load"
ondatabinding="datalistYorum_DataBinding">
<ItemTemplate>
<li class="comment">
<div class="comment-body">
<div class="comment-author vcard">
<div class="lightbox-photo">
<a class="image-overlay" href='<%# "Foto/profil/foto_buyuk/" + Eval("Yorum_Profil_Foto_Buyuk") %>' data-rel="prettyPhoto" title='<%# Eval("Yorum_UserName")%>'>
<img src='<%# "Foto/profil/foto_kucuk/" + Eval("Yorum_Profil_Foto_Kucuk") %>' alt='<%# Eval("Yorum_UserName")%>' class="avatar" />
</a>
</div>
<cite class="fn"><asp:HyperLink ID="linkProfil" runat="server" Text='<%# Eval("Yorum_UserName")%>' NavigateUrl='<%# "~/profil.aspx?user_id="+ Eval("User_ID") %>'></asp:HyperLink></cite>
<cite class="fn-time"><%# Eval("Yorum_Gecen_Zaman")%></cite>
</div>
<p><%# Eval("Yorum_Text")%></p>
<div class="reply"><asp:CheckBox ID="checkLike" runat="server" CssClass="comment-reply-link" AutoPostBack="True" />
<asp:ToggleButtonExtender ID="ToggleButtonLike" runat="server" TargetControlID ="checkLike" ImageHeight="32" ImageWidth="52" CheckedImageUrl="~/images/liked.png" UncheckedImageUrl="~/images/like.png" CheckedImageAlternateText="Like">
</asp:ToggleButtonExtender>
</div>
<div class="reply"><asp:CheckBox ID="checkDislike" runat="server" CssClass="comment-reply-link" AutoPostBack="True" />
<asp:ToggleButtonExtender ID="ToggleButtonDislike" runat="server" TargetControlID="checkDislike" ImageHeight="32" ImageWidth="62" UncheckedImageUrl="~/images/dislike.png" CheckedImageUrl="~/images/disliked.png">
</asp:ToggleButtonExtender>
</div>
</div>
</li>
</ItemTemplate>
</asp:DataList>
<asp:ObjectDataSource ID="ods_yorumlar" runat="server"
DataObjectTypeName="Yorum" TypeName="yonet" SelectMethod="PostYorumlariGetir"
ondatabinding="ods_yorumlar_DataBinding"
onselecting="ods_yorumlar_Selecting" onselected="ods_yorumlar_Selected">
<SelectParameters>
and code behind:
protected void datalistYorum_ItemDataBound(object sender, DataListItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType==ListItemType.AlternatingItem)
{
CheckBox checkLike = (CheckBox)e.Item.FindControl("checkLike");
CheckBox checkDislike = (CheckBox)e.Item.FindControl("checkDislike");
if (!Page.IsPostBack)
{
checkLike.CheckedChanged += new EventHandler(checkLike_CheckedChanged);
checkDislike.CheckedChanged += new EventHandler(checkDislike_CheckedChanged);
}
}
}
public void checkLike_CheckedChanged(object sender, EventArgs e)
{
object user_id = Membership.GetUser().ProviderUserKey;
DateTime event_date = DateTime.Now;
CheckBox checkLike = (CheckBox)datalistYorum.FindControl("checkLike");
if (checkLike.Checked == true)
{
try
{
using (SqlConnection baglanti = new SqlConnection(ConfigurationManager.ConnectionStrings["xxx"].ConnectionString.ToString()))
{
SqlCommand komut = new SqlCommand("sp_likeordislike", baglanti);
komut.CommandType = CommandType.StoredProcedure;
komut.Parameters.AddWithValue("#comment",1);
komut.Parameters.AddWithValue("#user_id", user_id);
komut.Parameters.AddWithValue("#likeordislike", 1);
komut.Parameters.AddWithValue("#event_date", event_date);
baglanti.Open();
komut.ExecuteNonQuery();
baglanti.Close();
}
}
catch (Exception)
{
throw;
}
}
}
But nothing happen.Thanks!

Unless you are adding the event handler for the 'checklike' Checkbox in Page_Load it looks as though the assignment is missing.
Change the 'checklike' Checkbox declaration as follows:
<asp:CheckBox ID="checkLike" runat="server" CssClass="comment-reply-link" AutoPostBack="True" OnCheckedChanged="checkLike_CheckedChanged" />

Try this:
protected void checkDislike_CheckedChanged(Object sender, EventArgs e)
{
CheckBox cb = (CheckBox) sender;
DataListItem item = (DataListItem) cb.NamingContainer;
//
//
}
Your markup will look like this:
<asp:CheckBox ID="checkDislike" runat="server" CssClass="comment-reply-link" AutoPostBack="True" OnCheckedChanged="checkDislike_CheckedChanged" />
Before trying this comment out all the other checkbox events
Check this link:

Related

ASP.NET repeater dynamic value

I try to use a repeater in repeater in ASP.NET, but I want to change datasource from every repeat.
My aspx markup is:
<div class="container px-4 py-5" id="custom-cards">
<asp:Repeater ID="RepeaterKategori" runat="server" OnItemDataBound="ItemBound">
<ItemTemplate>
<h2 class="pb-2 border-bottom"><%#Eval("kategoriAd") %></h2>
<div class="row row-cols-1 row-cols-md-3 g-4">
<asp:Repeater ID="RepeaterAltKategori" runat="server">
<ItemTemplate>
<div class="col">
<div class="card h-100">
<img src="<%#Eval("altkategoriResim") %>" class="card-img-top" alt="...">
<div class="card-body">
<h5 class="card-title"><%#Eval("altkategoriBaslik") %></h5>
<p class="card-text"><%#Eval("altkategoriAciklama") %></p>
</div>
<div class="card-footer">
<small class="text-muted">Teşekkürler : <%#Eval("altkategoriDestekci") %></small>
</div>
</div>
</div>
</ItemTemplate>
</asp:Repeater>
</div>
<div class="d-grid gap-2 my-4">
Tümünü Görüntüle
</div>
</ItemTemplate>
</asp:Repeater>
</div>
My aspx.cs code behind is:
rehber kod = new rehber();
protected void Page_Load(object sender, EventArgs e)
{
RepeaterKategori.DataSource = kod.getDataTable("SELECT KategoriAd FROM kategoriler");
RepeaterKategori.DataBind();
}
protected void ItemBound(object sender, RepeaterItemEventArgs args)
{
if (args.Item.ItemType == ListItemType.Item || args.Item.ItemType == ListItemType.AlternatingItem)
{
DataTable katsay = kod.getDataTable("SELECT * FROM altkategoriler");
int kategoris = katsay.Rows.Count;
for (int i = 1; i == kategoris; i++)
{
Repeater RepeaterAltKategori = (Repeater)args.Item.FindControl("RepeaterAltKategori");
RepeaterAltKategori.DataSource = kod.getDataTable("SELECT TOP 3 * FROM altkategoriler WHERE kategoriId="+i+"");
RepeaterAltKategori.DataBind();
}
}
}
I want another id data like 1,2,3,4 for every repeat. How can I do this? Thanks..
You need to nest two repeaters then.
You have
top table - feed the main repeater - 1 record for each.
child table - feed the child repeater - child table - many records for each.
Also, make sure you ALWAYS use if (!isPostBack) to have a real first page load - if you don't do most (if not all) of your loading and databinding inside of the !IsPostback?
you cannot even really quite much build a working page that can survive post-backs.
Ok, so we have the master (top) repeater.
for the child repeater, you might have one record, maybe many. It don't matter. But WHAT DOES matter is you now have a whole new seperate data set and whole new set of Eval() and binding that belongs to that child table or child data set.
So, lets take a main repeater (our hotels), and for each instance, we drop in another repeater to display the child data (in this case people booked in the hotel).
So, we have this mark-up - note the nested 2nd repeater.
<asp:Repeater ID="repHotels" runat="server" OnItemDataBound="repHotels_ItemDataBound">
<ItemTemplate>
<asp:Label ID="txtHotel" runat="server" Width="240px"
Text='<%# Eval("HotelName") %>' Font-Size="X-Large" >
</asp:Label>
<asp:TextBox ID="txtDescription" runat="server"
Text='<%# Eval("Description") %>'
TextMode="MultiLine" Rows="5" Columns="40" Style="margin-left:20px" >
</asp:TextBox>
<br />
<h4>People Booked</h4>
<asp:Repeater ID="repPeopleBooked" runat="server">
<ItemTemplate>
<asp:Label ID="lFirst" runat="server" Text='<%# Eval("FirstName") %>'>
</asp:Label>
<asp:Label ID="lLast" runat="server" Text='<%# Eval("LastName") %>'
style="margin-left:10px">
</asp:Label>
<br />
</ItemTemplate>
</asp:Repeater>
<%-- our repeat separator --%>
<div style="height:20px">
<hr style="border:1px solid" />
</div>
</ItemTemplate>
</asp:Repeater>
And our code to load. We ONLY load the main repeater data source, and THAT will trigger the item data bound event, and in that event then we deal with EACH separate instance of the child repeater.
Code like this:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
LoadData();
}
void LoadData()
{
SqlCommand cmdSQL = new SqlCommand("SELECT * from MyHotels ORDER BY HotelName");
repHotels.DataSource = MyRstP(cmdSQL);
repHotels.DataBind();
}
protected void repHotels_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if ( (e.Item.ItemType == ListItemType.Item) ||
(e.Item.ItemType == ListItemType.AlternatingItem))
{
// get child nested repeater
Repeater rChild = e.Item.FindControl("repPeopleBooked") as Repeater;
DataRowView rRow = ((DataRowView)e.Item.DataItem);
string strSQL = "SELECT * FROM People WHERE Hotel_ID = #id";
SqlCommand cmdSQL = new SqlCommand(strSQL);
cmdSQL.Parameters.Add("#id", SqlDbType.Int).Value = rRow["ID"];
rChild.DataSource = MyRstP(cmdSQL);
rChild.DataBind();
}
}
public DataTable MyRstP(SqlCommand cmdSQL)
{
DataTable rstData = new DataTable();
using (SqlConnection conn = new SqlConnection(Properties.Settings.Default.TEST4))
{
using (cmdSQL)
{
cmdSQL.Connection = conn;
conn.Open();
rstData.Load(cmdSQL.ExecuteReader());
}
}
return rstData;
}
and we now get this:
So, we see the 3 main records that drive the main repeater, and then we see the child records for the nested repeater.
Now, in your case, you might only ever have one child record - but it don't matter. What really matters is that you have the ability to deal with, and bind, and have separate Eval() and data for that child repeater.

Create a dropdown that filters the output of my repeater

I have a repeater that lists all the products in my Products table and I need a dropdown box to filter the repeater content by category_id. I have absolutely no idea what I'm doing. Here is my repeater:
<asp:Repeater ID="RShopItems" runat="server" ItemType="WebDevAssessment.Models.Product">
<ItemTemplate>
<div class="col-md-4 productOuterContainer">
<div class="col-md-10 col-md-offset-1 productInnerContainer border">
<a href='<%#"ProductDetails.aspx?item=" + Item.product_id %>' runat="server" target="_parent">
<img runat="server" alt='<%# Item.product_name %>' src='<%# Item.product_image1 %>'
style="width: 100%" class="img-thumbnail" />
</a>
<h4 class="text-center"><%# Item.product_name %></h4>
<p class="text-center">Size: <%#Item.product_size%> - $<%#Item.product_price%></p>
<p class="features_text text-center"><%#Item.product_feat_short%></p>
</div>
</div>
</ItemTemplate>
</asp:Repeater>
And the behind code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WebDevAssessment.Models;
namespace WebDevAssessment
{
public partial class Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
using (WebDatabaseEntities wde = new WebDatabaseEntities())
{
var products = (from si in wde.Products
orderby si.product_price descending
select si).ToList();
// assign the data to the repeater
RShopItems.DataSource = products;
// trigger the repeater to incorporate to display the data
RShopItems.DataBind();
}
}
}
}
Ok, you can use this apporach.
In this example, we have a repeater - showing hotel names.
We have a drop down list to filter by city (no choice = all cities).
So, the mark up looks like this:
<asp:DropDownList ID="DropDownList1" runat="server" DataTextField="City" DataValueField="ID" AutoPostBack="True">
</asp:DropDownList>
<br />
<br />
<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
<div style="border-style:solid;color:black;width:250px;float:left">
<div style="padding:5px;text-align:right">
Hotel Name: <asp:TextBox ID="txtHotelName" runat="server" Text ='<%# Eval("HotelName") %>' Width="130px" />
<br />
First Name: <asp:TextBox ID="txtFirst" runat="server" Text ='<%# Eval("FirstName") %>' Width="130px" />
<br />
Last Name: <asp:TextBox ID="txtLast" runat="server" Text ='<%# Eval("LastName") %>' Width="130px" />
<br />
City: <asp:TextBox ID="txtCity" runat="server" Text ='<%# Eval("City") %>' Width="130px" />
<br />
</div>
</div>
</ItemTemplate>
</asp:Repeater>
And the code to load up drop, load up Repeater, and filter looks like this:
protected void Page_Load(object sender, System.EventArgs e)
{
if (IsPostBack == false)
{
LoadDropDown();
LoadGrid();
}
}
public void LoadDropDown()
{
// load drop down list
using (SqlCommand cmdSQL = new SqlCommand("SELECT ID, City from tblCity ORDER BY City",
new SqlConnection(My.Settings.TEST3)))
{
cmdSQL.Connection.Open();
DropDownList1.DataSource = cmdSQL.ExecuteReader;
DropDownList1.DataBind();
// add blank row choice to drop down list
DropDownList1.Items.Insert(0, new ListItem(string.Empty, string.Empty));
}
}
public void LoadGrid(string sFilter = "")
{
using (SqlCommand cmdSQL = new SqlCommand("SELECT * FROM tblHotels",
new SqlConnection(My.Settings.TEST3)))
{
if (sFilter != "")
{
cmdSQL.CommandText += " WHERE City = #City";
cmdSQL.Parameters.Add("#City", SqlDbType.NVarChar).Value = DropDownList1.SelectedItem.Text;
}
cmdSQL.CommandText += " ORDER BY HotelName";
cmdSQL.Connection.Open();
Repeater1.DataSource = cmdSQL.ExecuteReader;
Repeater1.DataBind();
}
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
LoadGrid(DropDownList1.SelectedItem.Text);
}
So it now looks like this:
So, on first load - you load up the dropdown, and the repeater.
Dropdown list has auto post back = true, and it simply filters the Repeater by applying a parameters (optional) to the data source for the repeater.
It not a lot of code, and I don't see any advantages to using linq as you are.

E_name not exist in current context

this is my design part.
<asp:Panel ID="eventshow" Visible="false" runat="server" onclick="eventshow_click">
<asp:Repeater ID="allshowevent" runat="server">
<HeaderTemplate>
</HeaderTemplate>
<ItemTemplate runat="server">
<div id="eventab" runat="server">
<div>
<a runat="server" href='Event_Explore.aspx?CID=<%#Eval("CID") %>&FID=<%#Eval("FESTID") %>'>
<asp:Label ID="E_name" runat="server" Text='<%#Eval("EVENT_NAME") %>' onclick="E_nameClick"></asp:Label>
</a>
</div>
<div id="eventdate">
<p>Start Date:<%#Eval("START_DATE") %></p>
</div>
</div>
</ItemTemplate>
<FooterTemplate>
</FooterTemplate>
</asp:Repeater>
</asp:Panel>
this is .cs code
protected void E_nameClick(object sender, EventArgs e)
{
if (E_name.Text == "GROUP DANCE")
{
dan.Visible = true;
}
}
it shows e_name not exist in current context.please help me to solve this.
Thank you
Try using something like this:
protected void E_nameClick(object sender, EventArgs e)
{
Label myE_name = (Label)sender;
////if dan is inside the repeater then add the following line and replace Control with your control type
//Control dan = (Control)(((Label)sender).NamingContainer).FindControl("dan");
if (myE_name.Text == "GROUP DANCE")
{
dan.Visible = true;
}
}

ASP.Net dropdown always return first value on button click event

I am trying to save value from a simple asp.net form.
I have few controls on the page like drop-down & text-box's
I fill the first drop-down on page load with Language & trigger post-bask on same to fill the second drop-down ddCategoryType which it fills with correct values based on the language selected, but problem is when i try to get the value on button click event value for ddCategoryType.SelectedItem.Value always return 0 for some reason which i am not able figure out right now
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
ddSelectLanguage.Items.Clear();
ddSelectLanguage.DataSource = DataProvider.GetLanguages();
ddSelectLanguage.DataBind();
ddSelectLanguage.Items.Insert(0, new ListItem("Select Language", "0"));
}
else
{
ddCategoryType.Items.Clear();
String strSql = "SELECT TypeName, TypeID FROM CategoryType WHERE LangID =" + ddSelectLanguage.SelectedItem.Value.ToString();
DataSet ds = new DataSet();
ds = DataProvider.Connect_Select(strSql);
ddCategoryType.DataSource = ds;
ddCategoryType.DataBind();
ddCategoryType.Items.Insert(0, new ListItem("Select Type", "0"));
}
}
protected void btnSaveCategory_Click(object sender, EventArgs e)
{
objArtCat.LanguageID = int.Parse(ddSelectLanguage.SelectedItem.Value.ToString());
objArtCat.CategoryName = txtCategoryName.Text;
objArtCat.CategoryType = int.Parse(ddCategoryType.SelectedItem.Value.ToString());
objArtCat.CategoryActive = bool.Parse(ddCategoryActive.SelectedItem.Value.ToString());
try
{
//bool result;
//result = objBLAddArticleCategory.CreateNewArticleCategory(objArtCat);
//if (result == true)
//{
// Response.Redirect("PageMessage.aspx?msg='Category has been Create Successfully'", true);
//}
//else
//{
//}
}
catch (Exception)
{ }
}
SAMPLE .ASPX CODE
<div class="row"></div>
<div class="row">
<asp:Label ID="lblSelectLang" CssClass="txtLabel" Text="Select Language :" runat="server" ></asp:Label>
<asp:DropDownList ID="ddSelectLanguage" runat="server" CssClass="ddGeneral"
DataTextField="LangName" DataValueField="LangID" CausesValidation="True"
AutoPostBack="True" >
</asp:DropDownList>
<asp:RequiredFieldValidator ID="rfvddLanguage" runat="server" ErrorMessage="Please Select Language" ControlToValidate="ddSelectLanguage"
InitialValue="Select Language" ValidationGroup="atpAddNewArticle" ></asp:RequiredFieldValidator>
</div>
<div class="row">
<asp:Label ID="lblCategoryName" CssClass="txtLabel" runat="server" Text="Category Name :"></asp:Label>
<asp:TextBox ID="txtCategoryName" runat="server" CssClass="txtbox300"></asp:TextBox>
<asp:RequiredFieldValidator ID="RFVtxtAuthorName" runat="server" ErrorMessage="*"
ControlToValidate="txtCategoryName" ValidationGroup="atpAddNewArticle" CssClass="validation"></asp:RequiredFieldValidator>
</div>
<div class="row">
<asp:Label ID="lblCategoryType" CssClass="txtLabel" runat="server" Text="Category Type :"></asp:Label>
<asp:DropDownList ID="ddCategoryType" runat="server" CssClass="ddGeneral" DataTextField="TypeName" DataValueField="TypeID" >
</asp:DropDownList>
</div>
<div class="row">
<asp:Label ID="lblCategoryActive" CssClass="txtLabel" runat="server" Text="Category Active :"></asp:Label>
<asp:DropDownList ID="ddCategoryActive" runat="server" CssClass="ddGeneral" >
<asp:ListItem Value="False" Selected="True">NO</asp:ListItem>
<asp:ListItem Value="True">YES</asp:ListItem>
</asp:DropDownList>
</div>
<div class="rowButton">
</br>
<asp:Button ID="btnUpdateArticle" runat="server" Text="Save Category" CssClass="btn" ValidationGroup="atpAddNewArticle" onclick="btnSaveCategory_Click" /> <input id="Reset" type="reset" class="btn" value="Reset" />
</div>
OutPut for ddCategoryType after postback
<div class="row">
<span class="txtLabel" id="MainContent_lblCategoryType">Category Type :</span>
<select class="ddGeneral" id="MainContent_ddCategoryType" name="ctl00$MainContent$ddCategoryType">
<option value="0" selected="selected">Select Type</option>
<option value="1">Article</option>
<option value="2">News</option>
<option value="3">Sports</option>
<option value="4">People</option>
<option value="5">Message</option>
</select>
</div>
In your Page_Load you are clearing the contents of ddCategoryType and therefore the SelectedIndex is reset to 0.
Remember that the Page_Load is always called, and it happens BEFORE the Button_Click event.
There are a few ways to handle this, for instance: don't perform all the code in your Page_Load's else clause if the SelectedIndex >= 0
Since you want to populate ddCategoryType based on a selected value from ddSelectLanguage, then populate the DDL based on that interaction, not in the Page_Load.
protected void Page_Load(object sender, EventArgs e)
{
ddSelectLanguage.SelectedIndexChanged += new
EventHandler(ddSelectLanguage_SelectedIndexChanged);
if (!IsPostBack)
{
ddSelectLanguage.Items.Clear();
ddSelectLanguage.DataSource = DataProvider.GetLanguages();
ddSelectLanguage.DataBind();
ddSelectLanguage.Items.Insert(0, new ListItem("Select Language", "0"));
}
}
Then
void ddSelectLanguage_SelectedIndexChanged(object sender, EventArgs e)
{
ddCategoryType.Items.Clear();
String strSql = "SELECT TypeName, TypeID FROM CategoryType WHERE LangID =" + ddSelectLanguage.SelectedItem.Value.ToString();
DataSet ds = new DataSet();
ds = DataProvider.Connect_Select(strSql);
ddCategoryType.DataSource = ds;
ddCategoryType.DataBind();
ddCategoryType.Items.Insert(0, new ListItem("Select Type", "0"));
}
also, make your query take parameters.

asp.net HyperLink dynamic creation of NavigateUrl path

I have this in my asp.net page:
<% foreach (Product item in ProductList())
{
%>
<div id="i<%:item.CODE %>" class="item" dir="rtl">
<label class="code"><%:item.CODE %></label>
<asp:HyperLink runat="server" ID="DetailsLink" Text="Details"
NavigateUrl="~/Details.aspx?ProductCode=<%:item.CODE %>" font-size="18px"></asp:HyperLink>
</div>
<% } %>
Although the first <%:item.CODE%> works and I can see the item's code written,
in the NavigateUrl string it does not work.
I get a link to "http://localhost:34546/Details.aspx?ProductCode=<%:item.CODE %>"
How can I concat the item's code to the link?
Try this
<% foreach (String str in new string[] { "Apple", "Mango", "Orange" })
{
%>
<div id="i<%: str %>" class="item" dir="rtl">
<label class="code">
<%: str %></label>
<a href='<%: "Details.aspx?ProductCode=" + str %>'>DetailsLink</a>
</div>
<% } %>
instead of
<asp:HyperLink runat="server"
ID="DetailsLink"
Text="Details"
NavigateUrl="~/Details.aspx?ProductCode=<%:item.CODE %>"
font-size="18px"/>
You should use repeater control & handle its ItemDataBound event.
That will make you code cleaner & easy to debug.
in your .aspx.cs file:
protected void rpt_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
Product item = e.Item.DataItem as Product ;
HyperLink DetailsLink = e.Item.FindControl("DetailsLink") as HyperLink;
DetailsLink.NavigateUrl= "~/Details.aspx?ProductCode=" + item.CODE;
}
}
protected void Page_Load(object sender, EventArgs e)
{
rpt.DataSource = ProductList();
rpt.DataBind();
}
in your .aspx file:
<asp:Repeater ID="rpt" runat="server"> <ItemTemplate>
<asp:HyperLink runat="server" ID="DetailsLink" Text="Details"
font-size="18px"></asp:HyperLink>
</ItemTemplate>
</asp:Repeater>

Resources