Get value from data list on the button in the row clickSSSaravanakumar Sekaran11yAsked Jul 20, 2015, 1:52 AM EDT4 answersShareLinkedInXCopy linkSave Hi Guys, I want to get the value from the row of the data list control when i click the button which is inside the datalist row using jquery
Get value from data list on the button in the row clickSSSaravanakumar Sekaran11yAsked Jul 20, 2015, 1:52 AM EDT4 answersShareLinkedInXCopy linkSave Hi Guys, I want to get the value from the row of the data list control when i click the button which is inside the datalist row using jquery
GYGovinda Rajulu YemineniRank #1,518 · 1K reputation11y agoPosted Jul 20, 2015, 2:10 AM EDT0Hi saravana kumar, CodeCopyprivate void DataList1_ItemDataBound(object sender, System.Web.UI.WebControls.DataListIt emEventArgs e)CodeCopy{CodeCopy if (e.Item.ItemType == ListItemType.Item | e.Item.ItemType == ListItemType.Alternatin gItem)CodeCopy {CodeCopy string lblItemText = ((Label)e.Item.FindControl("lblItem")).Text;CodeCopy string lblPriceText = ((Label)e.Item.FindControl("lblPrice")).Text;CodeCopy LinkButton linkButton1 = (LinkButton)e.Item.FindControl("linkButton1");CodeCopy linkButton1.Attributes.Add("onClick", "JavaScript:GetText('" + lblItemText + "','" + lblPriceText + "')");CodeCopy }CodeCopy}CodeCopyCodeCopyand in JavascriptCodeCopyfunction GetText(item,Price)CodeCopy{CodeCopy alert("Item : " + item + " Price: " + Price);CodeCopy}If you find anything helpful please accept my answer.0
GYGovinda Rajulu YemineniRank #1,518 · 1K reputation11y agoPosted Jul 21, 2015, 1:56 AM EDT0Hi saravana kumar, try the below code function GetText(empno,empname,job,sal,deptno) { alert("Employee ID: " + empno + ", Employee Name: " + empname + ", Job: " + job + ", Salary: " + sal + ", Department No:" + deptno); } HorizontalAlign="Center" VerticalAlign="Middle" /> Employee Details Employee No: Employee Name: Job: Salary: Department: protected void Page_Load(object sender, EventArgs e) { if(!IsPostBack) { BindGridData(); } } private void BindGridData() { SqlConnection con = new SqlConnection("server=servername;Uid=uid;pwd=pwd;Database=dbname"); SqlCommand cmd = new SqlCommand("Select * from tablename", con); DataTable dt = new DataTable(); SqlDataAdapter da = new SqlDataAdapter(cmd); da.Fill(dt); if (dt.Rows.Count > 0) { DataList1.DataSource = dt; DataList1.DataBind(); } } protected void DataList1_ItemDataBound(object sender, DataListItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item | e.Item.ItemType == ListItemType.AlternatingItem) { string empno = ((Label)e.Item.FindControl("lblEmpNo")).Text; string empname = ((Label)e.Item.FindControl("lblEmpName")).Text; string job = ((Label)e.Item.FindControl("lblJob")).Text; string sal = ((Label)e.Item.FindControl("lblSal")).Text; string deptno = ((Label)e.Item.FindControl("lblDept")).Text; Button btn = (Button)e.Item.FindControl("btnGet"); btn.Attributes.Add("onClick", "JavaScript:GetText('" + empno + "','" + empname + "','" + job + "','" + sal + "','"+deptno+"')"); } } here i am selecting 2nd record CodeCopyCodeCopyCodeCopyIf you find anything helpful please accept my answer.0SSSaravanakumar SekaranRank #829 · 2.7K reputation11y agoPosted Jul 21, 2015, 5:44 AM EDT0very nice but i need to get the value to my form you coded for user control pls tell me how to get that value in aspx page which contains the user control liks above using Jquery.0GYGovinda Rajulu YemineniRank #1,518 · 1K reputation11y agoPosted Jul 21, 2015, 7:58 AM EDT0Hi saravana kumar, can you please elaborate your question more clearly0Join to answer this questionEvery answer you publish earns 20 SHARP.Create free accountSign inKnow the answer?Answer a question in the forums and earn +20 SHARP for every answer.See unanswered questionsForumsTop experts01Arun PottiAnswers in the forums20answers02Tahir AnsariAnswers in the forums5answers03Kamlesh KumarAnswers in the forums5answers04Sam HobbsAnswers in the forums4answers05Željko PerićAnswers in the forums3answers?YouYour name goes here.Every answer: 20 SHARP.JoinFull leaderboard →2026DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
SSSaravanakumar SekaranRank #829 · 2.7K reputation11y agoPosted Jul 21, 2015, 5:44 AM EDT0very nice but i need to get the value to my form you coded for user control pls tell me how to get that value in aspx page which contains the user control liks above using Jquery.0
GYGovinda Rajulu YemineniRank #1,518 · 1K reputation11y agoPosted Jul 21, 2015, 7:58 AM EDT0Hi saravana kumar, can you please elaborate your question more clearly0
Govinda Rajulu YemineniRank #1,518 · 1K reputationPosted Jul 20, 2015, 2:10 AM EDT
Govinda Rajulu YemineniRank #1,518 · 1K reputationPosted Jul 21, 2015, 1:56 AM EDT
Saravanakumar SekaranRank #829 · 2.7K reputationPosted Jul 21, 2015, 5:44 AM EDT
Govinda Rajulu YemineniRank #1,518 · 1K reputationPosted Jul 21, 2015, 7:58 AM EDT
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questionsTop experts