Hi
I am using Gridview . Names are dynamic. I want the values appearing to be as LinkButton. When user clicks Modal Popup should open. It should be without PostBack.
Image attached
Thanks
Hi
I am using Gridview . Names are dynamic. I want the values appearing to be as LinkButton. When user clicks Modal Popup should open. It should be without PostBack.
Image attached
Thanks
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Muhammad Imran AnsariRank #326 · 7.6K reputationPosted May 9, 2023, 3:41 AM EDT
You can achieve this by handling the RowDataBound event of the GridView control and converting the text of the cell to a LinkButton control. Then, you can add a JavaScript function to the OnClick attribute of the LinkButton to open the modal popup without a postback.
Here's an example code:
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { // Get the value of the cell you want to convert to a LinkButton // assuming the first column contains the value you want to convert string cellValue = e.Row.Cells[0].Text; // Create a new LinkButton control LinkButton linkButton = new LinkButton(); linkButton.Text = cellValue; // Add a JavaScript function to the OnClick attribute of the LinkButton to open the modal popup without a postback linkButton.OnClientClick = "showModalPopup('" + cellValue + "'); return false;"; // assuming there is a JavaScript function named 'showModalPopup' that takes the cell value as a parameter // Replace the text of the cell with the LinkButton control e.Row.Cells[0].Controls.Clear(); e.Row.Cells[0].Controls.Add(linkButton); } }