Click here to Skip to main content
15,877,637 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I want to popup data of selected row when user click the linkbutton inside the gridview. But its not working properly now, please help me to solve this.
Linkbutton in gridview:
<asp:TemplateField ShowHeader="False">
<asp:LinkButton ID="LinkButton1" CausesValidation="false"  runat="server" Text="Edit" OnClick="lnkapprove_Click"></asp:LinkButton>                       

protected void lnkapprove_Click(object sender, EventArgs e)
       GridViewRow row = (GridViewRow)btn.NamingContainer;
       int selectedIndexInPage = Convert.ToInt32(row.RowIndex);
       int pagesize = GridView1.PageSize;
       int pageindex = GridView1.PageIndex;
       int i = selectedIndexInPage + pageindex * pagesize;
       CurrentCard = CurrentDataTable.Clone();
       //Bind data to the hidden Div
       imgR1.ImageUrl = Page.ResolveUrl(CurrentCard.Rows[0]["picUrl"].ToString().Trim());
       txtPicR1.Text = CurrentCard.Rows[0]["picUrl"].ToString().Trim();
       imgR4.ImageUrl = CurrentCard.Rows[0]["picR4"].ToString().Trim();
       txtPicR4.Text = Page.ResolveUrl(CurrentCard.Rows[0]["picR4"].ToString().Trim());
       txtName.Text = CurrentCard.Rows[0]["name"].ToString().Trim();


$('[id*="LinkButton1"]').click(function (event) {
                 setTimeout(function () { // then show popup, deley in .5 second
                     loadPopup(); // function show popup
                 }, 500); // .5 second
                 return false;

With above jquerry function, it does show popup without trigger lnkapprove_Click event.
if i remove
return false;
or set its to true, the popup show first but without any data then close after page completely loaded.
So i want to after page completely loaded it will execute the jquerry later to properly display the popup with data.
Please help me to solve this, thanks :).
Mahesh Bailwal 30-Jun-13 9:56am    
can you share your loadPopup function code.
Ngoc Diep Mai 30-Jun-13 15:16pm    
Hi here it is:
<pre lang="Javascript">
$("div.close").click(function () {
disablePopup(); // function close pop up

$(this).keyup(function (event) {
if (event.which == 27) { // 27 is 'Ecs' in the keyboard
disablePopup(); // function close pop up

$("div#backgroundPopup").click(function () {
disablePopup(); // function close pop up

function loading() {
function closeloading() {

var popupStatus = 0; // set value

function loadPopup() {
if (popupStatus == 0) { // if value is 0, show popup
closeloading(); // fadeout loading
$("#toPopup").fadeIn(0500); // fadein popup div
$("#backgroundPopup").css("opacity", "0.7"); // css opacity, supports IE7, IE8
popupStatus = 1; // and set value to 1

function disablePopup() {
if (popupStatus == 1) { // if value is 1, close popup
popupStatus = 0; // and set value to 0

If you are using jQuery popup hope your popup code will be like this
  $(function() {
    $( "#dialog" ).dialog();

and your id name must be the same name which you are used in popup function you can call this function using script manager on click of link button
Share this answer
Ngoc Diep Mai 1-Jul-13 5:11am    
I was able to call both javascript function and c# function of linkbutton.
But as i mention above, with javascript return false; its will so popup but without any data is that popup (c# function never triggered).
With javascript return true, it show popup first then do postback==> user cant not see popup.
Are you coded correctly funation : loadPopup() ??
As coder am recommend to use ajax model pop-up Please see below link:[^]
Share this answer
Ngoc Diep Mai 1-Jul-13 5:14am    
Thanks will try on it :")

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