I want to upgrade from telerik 2006 to telerik Web 2010 so I use version trial Q1 2010.
I created columns of RadGrid in code behind (OnInit).
Here is my code
In aspx page
<telerik:RadGrid ID = "gridTemp" runat = "server" AutoGenerateColumns="false"
OnNeedDataSource="OnNeedDataSource" OnItemDataBound="gridTemp_ItemDataBound">
<MasterTableView AutoGenerateColumns="false" AllowSorting="true" AllowFilteringByColumn="true"
EnableViewState="false" EnableColumnsViewState="false">
<AlternatingItemStyle CssClass="CssAlternatingItem" />
<ItemStyle CssClass="CssItem" />
<NoRecordsTemplate><%=ML("Norecordtodiplay")%></NoRecordsTemplate>
</MasterTableView>
<ClientSettings>
<ClientEvents OnColumnResized="ChangeStatus();" OnColumnSwapped="ChangeStatus();" />
</ClientSettings>
</telerik:RadGrid >
In aspx.cs page
..............
foreach (Column column in caseOverviewXml.ListColumn)
{
if (string.Compare(column.Name.ToLower(), "allconversationsid") == 0)
{
DynamicTemplate mt = new DynamicTemplate(ListItemType.Item);
Label lblColor = new Label();
lblColor.ID = "lblColor";
mt.AddControl(lblColor, string.Empty, string.Empty);
GridTemplateColumn templateColumn = new GridTemplateColumn();
templateColumn.ItemTemplate = mt;
templateColumn.UniqueName = column.Name;
templateColumn.OrderIndex = orderIndex;
templateColumn.AllowFiltering = false;
switch (Request.QueryString["lang"])
{
case "de":
templateColumn.HeaderText = column.Caption_de;
break;
case "en":
templateColumn.HeaderText = column.Caption_en;
break;
case "fr":
templateColumn.HeaderText = column.Caption_fr;
break;
case "it":
templateColumn.HeaderText = column.Caption_it;
break;
default:
templateColumn.HeaderText = column.Caption_en;
break;
}
gridTemp.MasterTableView.Columns.Add(templateColumn);
}
else
{
GridHyperLinkColumn boundColumn = new GridHyperLinkColumn();
column.Name = column.Name.Replace("@LANG", Request.QueryString["lang"]);
boundColumn.UniqueName = column.Name;
boundColumn.DataTextField = column.Name;
boundColumn.ShowSortIcon = true;
boundColumn.SortExpression = column.Name;
boundColumn.ItemStyle.Wrap = true;
boundColumn.OrderIndex = orderIndex;
boundColumn.ShowFilterIcon = false;
boundColumn.AllowFiltering = true;
boundColumn.CurrentFilterFunction = GridKnownFunction.Contains;
boundColumn.AutoPostBackOnFilter = true;
switch (Request.QueryString["lang"])
{
case "de":
boundColumn.HeaderText = column.Caption_de;
break;
case "en":
boundColumn.HeaderText = column.Caption_en;
break;
case "fr":
boundColumn.HeaderText = column.Caption_fr;
break;
case "it":
boundColumn.HeaderText = column.Caption_it;
break;
default:
boundColumn.HeaderText = column.Caption_en;
break;
}
boundColumn.DataNavigateUrlFormatString =
"/Default.aspx?caseId={0}&ConversationID={1}&lang=" + Request.QueryString["lang"];
boundColumn.DataNavigateUrlFields = new string[]
{
"CaseId", "NavigationLastConversationId"
};
if (!string.IsNullOrEmpty(column.Width))
{
boundColumn.HeaderStyle.Width =
new Unit(ConvertHelper.ToDouble(column.Width));
}
gridTemp.MasterTableView.Columns.Add(boundColumn);
} // end else
orderIndex++;
} // end foreach
Filter problem : I cannot press Enter to filter because it not postback
Sort problem : The first it sort success, in the second or the third it occur error :"
Could you help me ?
I created columns of RadGrid in code behind (OnInit).
Here is my code
In aspx page
<telerik:RadGrid ID = "gridTemp" runat = "server" AutoGenerateColumns="false"
OnNeedDataSource="OnNeedDataSource" OnItemDataBound="gridTemp_ItemDataBound">
<MasterTableView AutoGenerateColumns="false" AllowSorting="true" AllowFilteringByColumn="true"
EnableViewState="false" EnableColumnsViewState="false">
<AlternatingItemStyle CssClass="CssAlternatingItem" />
<ItemStyle CssClass="CssItem" />
<NoRecordsTemplate><%=ML("Norecordtodiplay")%></NoRecordsTemplate>
</MasterTableView>
<ClientSettings>
<ClientEvents OnColumnResized="ChangeStatus();" OnColumnSwapped="ChangeStatus();" />
</ClientSettings>
</telerik:RadGrid >
In aspx.cs page
..............
foreach (Column column in caseOverviewXml.ListColumn)
{
if (string.Compare(column.Name.ToLower(), "allconversationsid") == 0)
{
DynamicTemplate mt = new DynamicTemplate(ListItemType.Item);
Label lblColor = new Label();
lblColor.ID = "lblColor";
mt.AddControl(lblColor, string.Empty, string.Empty);
GridTemplateColumn templateColumn = new GridTemplateColumn();
templateColumn.ItemTemplate = mt;
templateColumn.UniqueName = column.Name;
templateColumn.OrderIndex = orderIndex;
templateColumn.AllowFiltering = false;
switch (Request.QueryString["lang"])
{
case "de":
templateColumn.HeaderText = column.Caption_de;
break;
case "en":
templateColumn.HeaderText = column.Caption_en;
break;
case "fr":
templateColumn.HeaderText = column.Caption_fr;
break;
case "it":
templateColumn.HeaderText = column.Caption_it;
break;
default:
templateColumn.HeaderText = column.Caption_en;
break;
}
gridTemp.MasterTableView.Columns.Add(templateColumn);
}
else
{
GridHyperLinkColumn boundColumn = new GridHyperLinkColumn();
column.Name = column.Name.Replace("@LANG", Request.QueryString["lang"]);
boundColumn.UniqueName = column.Name;
boundColumn.DataTextField = column.Name;
boundColumn.ShowSortIcon = true;
boundColumn.SortExpression = column.Name;
boundColumn.ItemStyle.Wrap = true;
boundColumn.OrderIndex = orderIndex;
boundColumn.ShowFilterIcon = false;
boundColumn.AllowFiltering = true;
boundColumn.CurrentFilterFunction = GridKnownFunction.Contains;
boundColumn.AutoPostBackOnFilter = true;
switch (Request.QueryString["lang"])
{
case "de":
boundColumn.HeaderText = column.Caption_de;
break;
case "en":
boundColumn.HeaderText = column.Caption_en;
break;
case "fr":
boundColumn.HeaderText = column.Caption_fr;
break;
case "it":
boundColumn.HeaderText = column.Caption_it;
break;
default:
boundColumn.HeaderText = column.Caption_en;
break;
}
boundColumn.DataNavigateUrlFormatString =
"/Default.aspx?caseId={0}&ConversationID={1}&lang=" + Request.QueryString["lang"];
boundColumn.DataNavigateUrlFields = new string[]
{
"CaseId", "NavigationLastConversationId"
};
if (!string.IsNullOrEmpty(column.Width))
{
boundColumn.HeaderStyle.Width =
new Unit(ConvertHelper.ToDouble(column.Width));
}
gridTemp.MasterTableView.Columns.Add(boundColumn);
} // end else
orderIndex++;
} // end foreach
Filter problem : I cannot press Enter to filter because it not postback
Sort problem : The first it sort success, in the second or the third it occur error :"
Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation."
Could you help me ?