Jump to content

Add Hyperlinlfield To Grid View


lbenezra

Recommended Posts

I want to add a hyperlinkfield dinamicly to grid view in a tab control . the data for the grid view is class category.products, I want to add field that will be a link to aspx file with the item name field as a parameter .: ========================================== List<Category> categories = Category.GetCategories(activityID,DataPlace); foreach (Category category in categories) { GridView gv = new GridView(); HyperLinkField Hyperlink1 = new HyperLinkField(); gv.DataSource = category.Products; //add hyper link field to grid // Hyperlink1.DataNavigateUrlFields = "productName"; <---- I have proble, with this line - it expected to string[] and not string ------> Hyperlink1.DataNavigateUrlFormatString = "contactN_en.aspx?productID={0}&industry_id=" + industryID + "&activity_id=" + activityID; // Hyperlink1.NavigateUrl = "contactN_en.aspx?industry_id="+ industryID+ "&activity_id="+activityID; Hyperlink1.DataTextField = "productName"; gv.Columns.Add(Hyperlink1); gv.DataBind(); gv.HeaderRow.Visible = false; AjaxControlToolkit.TabPanel tab = new AjaxControlToolkit.TabPanel(); tab.Controls.Add(gv); tab.HeaderText = category.CategoryName; TabContainer1.Tabs.Add(tab); } } TabContainer1.ActiveTabIndex = 0;================================================product calss:ublic class Product{ // private int productID; private string productName; //public int ProductID //{ // get { return this.productID; } // set { this.productID = value; } //} public string ProductName { get { return this.productName; } set { this.productName = value; } }====================================category class:public class Category: System.Web.UI.Control{ private int categoryID; private string categoryName; private List<Product> products; public int CategoryID { get { return this.categoryID; } set { this.categoryID = value; } } public string CategoryName { get { return this.categoryName; } set { this.categoryName = value; } } public List<Product> Products { get { return this.products; } set { this.products = value; } }=================================

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...