Click here to Skip to main content
14,695,660 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i have Grid view and form View and i need to show popup modal windows if user clicked
on edit or delete button in Grid View need to fire the modal window ??
how i can do that?
Posted

1 solution

user clicked on edit or delete button in Grid View need to fire the modal window
You need to inject JavaScript at row level of the grid. You would need to use RowDataBound event of grid that triggers on every row bind. In this, inject JS code to open the modalpopup on click of a control.
Sample:
//For injecting JS, you need to use RowDataBound of GridView, something like:
protected void GridView_RowDataBound(Object sender, GridViewRowEventArgs e)
{ 
   DataControlRowType rtype = e.Row.RowType;  
   if (rtype == DataControlRowType.DataRow)  
   { 
      // Control specific
      LinkButton l = (LinkButton)e.Row.FindControl("LinkButton1");
      l.Attributes.Add("onclick", "javascript: OpenModalDialogMethodDefinedInJS();"); 
   }
}


Refer: Using JavaScript with ASP.Net GridView Control[^]
   
Comments
VJ Reddy 6-Jun-12 5:30am
   
Good answer. 5!
Sandeep Mewara 6-Jun-12 7:15am
   
Thanks.
sysnosis 20-Jul-12 6:52am
   
how to make chat application like facebook in asp.net ..
Please provide solution with dem
o

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