Click here to Skip to main content
15,895,799 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, All

Here i am facing problem with Repeater control, i am not using any control in repeater, so how can i get the row value from row which selected by user

Thank You !
Posted
Comments
Prakriti Goyal 21-Aug-14 1:40am    
Mention your code.
prasanna.raj 21-Aug-14 1:42am    
i have no idea to do this... if i am using ItemDatabing it not working properly for me...
prasanna.raj 21-Aug-14 1:44am    
i have no idea for this one if i'm using item databound its not working properly
Prakriti Goyal 21-Aug-14 1:59am    
Please elaborate or provide your code
prasanna.raj 21-Aug-14 2:31am    
{ if (IsPostBack)
{
string arg = Request["__EVENTARGUMENT"];
if (string.IsNullOrEmpty(arg) == false)
{
if (arg.StartsWith("row"))
{
string v = arg.Substring(arg.IndexOf("#") + 1);
txtSelected.Text = v;
}
}
}
//Have to bind repeater always
con.Open();
string Qry = "select sm.UserIdN,sm.EmpCodeC,sm.empnamec,sm.deptcodec,sm.seccodec,CONVERT(varchar(10),sm.Dojd,103) as Dojd,sm.NricWPNoC,sm.LeaveCodeC,sm.ShiftGroupCodeC,sm.LocationC,CONVERT(varchar(10),sm.TerminateDateD,103)as TerminateDateD,sm.Gender,CONVERT(varchar(10),sm.DOB,103)as DOB,dsm.Privilege,dsm.Password,dsm.Enabled,dsm.CardNumber from StaffMaster sm inner join Device_StaffFP dsm on sm.UserIDN=dsm.UserIDN";
DataTable Dtab = new DataTable();
SqlDataAdapter da = new SqlDataAdapter(Qry, con);
da.Fill(Dtab);
Repeater1.DataSource = Dtab;
Repeater1.DataBind();
}

protected string getPostbackReference(string Name)
{
return ClientScript.GetPostBackEventReference(this, "rowEvent#" + Name);
}

<itemtemplate>
<p önclick="<%# getPostbackReference((string)Container.DataItem) %>">
<%# Container.DataItem %></p>

The Repeater control does not expose DataKeys. You may not get selected row value from the Repeater control without having any controls in it rather you can use checkbox and hidden field

here is an example of that:

http://forums.asp.net/p/1257926/2345904.aspx[^]
 
Share this answer
 
Either you have to put a Button or something and handle the ItemCommand Event. Inside that event, you can get the Selected Row details.

Else you can attach one onclick client side event to the Repeater Row and inside that JavaScript Event, you can get the details of the row.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900