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.NET
<asp:TemplateField ShowHeader="False">
<ItemTemplate>                      
<asp:LinkButton ID="LinkButton1" CausesValidation="false"  runat="server" Text="Edit" OnClick="lnkapprove_Click"></asp:LinkButton>                       
</ItemTemplate>
</asp:TemplateField>

lnkapprove_Click
C#
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();
       CurrentCard.ImportRow(CurrentDataTable.Rows[i]);
       //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();

   }

Jquerry:
JavaScript
$('[id*="LinkButton1"]').click(function (event) {
                 loading();
                 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
JavaScript
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 :).
Posted
Comments
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() {
$("div.loader").show();
}
function closeloading() {
$("div.loader").fadeOut('normal');
}

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
$("#backgroundPopup").fadeIn(0001);
popupStatus = 1; // and set value to 1
}
}

function disablePopup() {
if (popupStatus == 1) { // if value is 1, close popup
$("#toPopup").fadeOut("normal");
$("#backgroundPopup").fadeOut("normal");
popupStatus = 0; // and set value to 0
}
}
</pre>

If you are using jQuery popup hope your popup code will be like this
JavaScript
<script>
  $(function() {
    $( "#dialog" ).dialog();
  });
  </script>


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
 
Comments
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 linkbutton.click javascript return false; its will so popup but without any data is that popup (c# function never triggered).
With linkbutton.click javascript return true, it show popup first then do postback==> user cant not see popup.
Are you coded correctly funation : loadPopup() ??
As asp.net coder am recommend to use ajax model pop-up Please see below link:
http://www.ajaxcontroltoolkit.com/ModalPopup/ModalPopup.aspx[^]
 
Share this answer
 
Comments
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