I am using Telerik.Web.UI 2009.1.311.20. I have a grid in a master page and I am creating its structure and populating it from the content pages. This is the code I use in a content page:
The problem I have is that whenever I do a post back (by sorting the grid or navigating to a different grid page), the GridTemplateColumn is no longer shown. Any suggestions on how to fix this?
| protected new void Page_Load(object sender, EventArgs e) |
| { |
| ContentPlaceHolder cph = Master.Master.FindControl("PageContents") as ContentPlaceHolder; |
| RadGrid grid = cph.FindControl("RadGrid1") as RadGrid; |
| if(!IsPostBack) |
| { |
| DefineGridStructure(grid); |
| } |
| PopulateGrid(grid); |
| } |
| public override void DefineGridStructure(RadGrid grid) |
| { |
| grid.MasterTableView.DataKeyNames = new string[] { "CustomerID", "Name"}; |
| GridBoundColumn boundColumn; |
| GridTemplateColumn templateColumn; |
| boundColumn = new GridBoundColumn(); |
| grid.MasterTableView.Columns.Add(boundColumn); |
| boundColumn.DataField = "Name"; |
| boundColumn.HeaderText = Resources.Strings.Name; |
| templateColumn = new GridTemplateColumn(); |
| grid.MasterTableView.Columns.Add(templateColumn); |
| templateColumn.DataField = "CustomerId"; |
| templateColumn.HeaderText = ""; |
| templateColumn.AllowFiltering = false; |
| templateColumn.ItemTemplate = new ImageLinkTemplate("CustomerId", "~/Images/View.gif", |
| "CustomersView.aspx", Resources.Strings.View); |
| } |
| public override void PopulateGrid(RadGrid grid) |
| { |
| CustomerService service = new CustomerService(); |
| grid.DataSource = service.GetGridData(base.GetCompanyId()); |
| } |
The problem I have is that whenever I do a post back (by sorting the grid or navigating to a different grid page), the GridTemplateColumn is no longer shown. Any suggestions on how to fix this?