Click here to Skip to main content
16,018,114 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi, Below is my code used to Genrate a Link Button in the dynamci genrated Gridview.
i dynamically get the details of the column whom i have to make link button , so i do the operation on RowBound.

i am able to open the new window from javascript on click of the respective link button click. But when i click on the linkbutton and when i return back to my page all the Link in the gridView Disable and i am not able to click on other link again.

Help please

Thanks :)



C#
protected void grdDisplayRequest_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            Dictionary<string, int> DictionaryCloumnName = Session["DictionaryCloumnName"] as Dictionary<string, int>;//Session containing the Column name and the Column ID.
            Dictionary<string, string> FKeyName = new Dictionary<string, string>();
            FKeyName = Session["Fkeys"] as Dictionary<string, string>;//Session contain the list of ForeignKeys.
            string TableName = Session["OperatingTableName"] as string;//Session Contain the Selected Table Name.
            if (e.Row.RowType == DataControlRowType.DataRow)//Check whether RowType is DataRow , so that we can update the Rows of the GridView.
            {
                foreach (KeyValuePair<String, String> entry in FKeyName)//iterating the loop to get the Name of ForeignKey and Table related to that ForeignKey.
                {
                    if (DictionaryCloumnName.ContainsKey(entry.Key))//Check for the ColumnName present in the Dictionary.
                    {
                        int i = DictionaryCloumnName[entry.Key];//Index of the ForeignKey Column.
                        LinkButton link = new LinkButton();
                        link.Text = e.Row.Cells[i].Text;//Text of the Column who we want to convert to Link.
                        link.CommandArgument = "onclick";
                        link.Attributes["onclick"] = "popwin('" + entry.Value + "');";//Adding attributes to the link button, adding the JavaScript Function name who will call the New Pop Window.
                        e.Row.Cells[i].Controls.Add(link);//Adding the Row containing the LinkButton to the GridView.
                    }
                }
            }
        }
Posted
Updated 16-Apr-12 11:45am
v2
Comments
Nelek 16-Apr-12 17:46pm    
Edit: Changed code tag
sawant parag 17-Apr-12 5:42am    
hi Nelek,

What do u mean by this "Edit: Changed code tag" ?

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