Quantcast
Channel: ASP.NET AJAX + Ajax Control Toolkit (ACT)
Viewing all articles
Browse latest Browse all 5678

Link Button Behavior in a GridView for Modal Popup

$
0
0

I have a GridView in a usercontrol which gets data dynamically from a data table; a new column is added to GridView1 when during DataBind. I am having an issue and need help with:
When Link Button is clicked; the html for the Popup is displayed on the main page first and then the Popup shows up and the html for popup disappear.

What am I doing wrong?

protected void Page_Load(object sender, EventArgs e)
        {
	     if(!IsPostBack)
              {
                 this.BindGrid();
              }
        }

        private void BindGrid()
        {
            string constr = ConfigurationManager.ConnectionStrings["ConnString"].ConnectionString;
            using (SqlConnection con = new SqlConnection(constr))
            {
                using (SqlCommand cmd = new SqlCommand("SELECT * FROM Employees"))
                {
                    using (SqlDataAdapter sda = new SqlDataAdapter())
                    {
                        cmd.Connection = con;
                        sda.SelectCommand = cmd;
                        using (DataTable dt = new DataTable())
                        {
                            dt.Columns.AddRange(new DataColumn[1] { new DataColumn("View", typeof(int)) });
                            sda.Fill(dt);
                            GridView1.DataSource = dt;
                            GridView1.DataBind();
                        }
                    }
                }
            }
        }

        protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                LinkButton lnkView = new LinkButton();
                lnkView.ID = "lnkActions";
                lnkView.Text = "View";
                lnkView.Click += ViewDetails;
                lnkView.CommandArgument = (e.Row.DataItem as DataRowView).Row["EmpID"].ToString();
                e.Row.Cells[0].Controls.Add(lnkView);
            }
        }
        protected void ViewDetails(object sender, EventArgs e)
        {
            LinkButton lnkActions = (LinkButton)sender;
            lnkActions.OnClientClick = "return false";
            GridViewRow row = (lnkActions.NamingContainer as GridViewRow);
            string sEmpID = lnkActions.CommandArgument;
            string name = row.Cells[2].Text;

            mpeThePopup.Show();
        }


Viewing all articles
Browse latest Browse all 5678

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>