Hi All
i want to some thing similar to that which i have attached with this post. but i am facing following exeption and dont know what to do.
Line 332: <td style="font-size: 8pt; font-family: Verdana" align="left"> Line 333: Code:<br> Line 334: <asp:TextBox ID="TextBox1" runat="server" Font-Size="8pt" Width="190px" columnKey="Code" Line 335: Font-Name="Verdana" Font-Names="Verdana" Text='<%# Eval("Code") %>'></asp:TextBox></td> Line 336: </tr>
[InvalidOperationException: Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control.] System.Web.UI.Page.GetDataItem() +2647882 System.Web.UI.TemplateControl.Eval(String expression) +31 ASP.lookups_currencymanagement_aspx.__DataBinding__control42(Object sender, EventArgs e) in d:\ideaGate\Projects\AL-Sarraf\Prototype\Main\Bizlogix\Lookups\CurrencyManagement.aspx:334 System.Web.UI.Control.OnDataBinding(EventArgs e) +99 System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +92 System.Web.UI.Control.DataBind() +15 System.Web.UI.Control.DataBindChildren() +211 System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +102 System.Web.UI.Control.DataBind() +15 Infragistics.WebUI.UltraWebGrid.DBBinding.BindList(IEnumerable datasource) +760 Infragistics.WebUI.UltraWebGrid.DBBinding.DataBind(Object dataSource, String dataMember) +950 Infragistics.WebUI.UltraWebGrid.UltraWebGrid.DataBind() +405 Lookups_CurrencyManagement.BindGridData() in d:\ideaGate\Projects\AL-Sarraf\Prototype\Main\Bizlogix\Lookups\CurrencyManagement.aspx.cs:99 Lookups_CurrencyManagement.Page_Load(Object sender, EventArgs e) in d:\ideaGate\Projects\AL-Sarraf\Prototype\Main\Bizlogix\Lookups\CurrencyManagement.aspx.cs:22 System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14 System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35 System.Web.UI.Control.OnLoad(EventArgs e) +99 System.Web.UI.Control.LoadRecursive() +50 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627
Version Information: Microsoft .NET Framework Version:2.0.50727.3053; ASP.NET Version:2.0.50727.3053
Here is Code Behind:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Infragistics.WebUI.UltraWebGrid;
public partial class Lookups_CurrencyManagement : System.Web.UI.Page
{
}
TemplatedColumn tc = null;
tc = (TemplatedColumn) grdEnglishCurrencies.Columns[0];
radio = (CheckBox) cnt.FindControl("chkSelect");
count++;
else
//DataTable tblCurrencies = new DataTable();
tblCurrencies.Columns.Add(new DataColumn("Code"));
tblCurrencies.Columns.Add(new DataColumn("Description"));
tblCurrencies.Columns.Add("Coin");
tblCurrencies.Columns.Add("CalBasisDays");
tblCurrencies.Columns.Add("DefCurrency");
row["ID"] = 1;
row["Title"] = "Title";
row["Sign"] = "$";
row["LeastDecValue"] = "2";
row["ExchRate"] = "34";
tblCurrencies.Rows.Add(row);
Here is Aspx Page:
<%@ Register assembly="Infragistics2.WebUI.UltraWebGrid.v8.2, Version=8.2.20082.1000, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb" namespace="Infragistics.WebUI.UltraWebGrid" tagprefix="igtbl" %>
<%@ Register assembly="Infragistics2.WebUI.Misc.v8.2, Version=8.2.20082.1000, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb" namespace="Infragistics.WebUI.Misc" tagprefix="igmisc" %>
contentplaceholderid="ContentPlaceHolder1">
<script type="text/javascript">
igtbl_getElementById(ctrlId).Text=value;
igtbl_getElementById(ctrlId).Value=(d.getMonth()+1).toString()+"/"+d.getDate()+"/"+d.getFullYear();
igtbl_getElementById(ctrlId).innerText=value;
igtbl_getCellById(cellId).setValue(igtbl_getElementById(ctrlId).TextWithMask);
igtbl_getCellById(cellId).setValue(igtbl_getElementById(ctrlId).Value);
igtbl_getCellById(cellId).setValue(s);
</script>
<table style="width: 100%">
<tr>
<td colspan="4">
Text="Currency Management" Font-Bold="True" Font-Size="Small"></asp:Label>
</td>
<td>
</td>
</tr>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<td align="right">
ImageUrl="~/Images/printer.gif" />
<asp:UpdatePanel ID="UpdatePanel4" runat="server">
<ContentTemplate>
<asp:Label ID="lblMessage" runat="server" Font-Bold="True" ForeColor="#990000"></asp:Label>
</ContentTemplate>
</asp:UpdatePanel>
Text="Add New" />
<td style="width: 84px" colspan="2">
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
Text="Delete" Enabled="False" />
<td style="width: 536px">
<td style="height: 8px;">
<td style="width: 84px; height: 8px;" colspan="2">
<td style="width: 536px; height: 8px;">
<td style="height: 8px">
<td colspan="4" style="height: 82px">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
Width="80%" ontabclick="UltraWebTab1_TabClick">
<Tabs>
<igtab:Tab Text="English" Tooltip="Enter Data in English Language">
Width="80%" >
<DisplayLayout CompactRendering="False" StationaryMargins="HeaderAndFooter" AllowSortingDefault="Yes"
RowHeightDefault="20px" RowSizingDefault="Free" Version="2.00.5000"
SelectTypeRowDefault="Single" AllowColumnMovingDefault="OnServer" SelectTypeCellDefault="Extended"
BorderCollapseDefault="Separate" AllowColSizingDefault="Free" Name="UltraWebGrid1"
AutoGenerateColumns="False">
<FrameStyle Width="100%" Cursor="Default" BorderWidth="1px" Font-Size="7pt" Font-Names="Verdana"
BorderStyle="Solid" BackColor="#E0E0E0" Height="338px">
</FrameStyle>
<ClientSideEvents AfterRowTemplateOpenHandler="arto" TemplateUpdateControlsHandler="TemplateUpdateControls"
TemplateUpdateCellsHandler="TemplateUpdateCells"></ClientSideEvents>
<Pager>
<PagerStyle BackColor="LightGray" BorderStyle="Solid" BorderWidth="1px">
WidthTop="1px" />
</PagerStyle>
</Pager>
<EditCellStyleDefault BorderStyle="None" BorderWidth="0px">
</EditCellStyleDefault>
<FooterStyleDefault BorderWidth="1px" BorderStyle="Solid" BackColor="LightGray">
<BorderDetails ColorTop="White" WidthLeft="1px" WidthTop="1px" ColorLeft="White"></BorderDetails>
</FooterStyleDefault>
<HeaderStyleDefault VerticalAlign="Middle" BorderWidth="1px" BorderStyle="Solid"
HorizontalAlign="Left" BackColor="LightGray" Height="20px">
<Padding Left="3px" Right="3px"></Padding>
<BorderDetails ColorTop="White" WidthLeft="1px" ColorBottom="Gray" WidthTop="1px"
ColorRight="Gray" ColorLeft="White"></BorderDetails>
</HeaderStyleDefault>
<RowSelectorStyleDefault Width="16px" BorderStyle="Solid" BackColor="White">
<BorderDetails WidthLeft="0px" ColorBottom="224, 224, 224" WidthTop="0px" WidthRight="0px"
WidthBottom="1px"></BorderDetails>
</RowSelectorStyleDefault>
<RowStyleDefault TextOverflow="Ellipsis" VerticalAlign="Middle" BorderWidth="1px"
Font-Size="8pt" Font-Names="Verdana" BorderColor="LightGray" BorderStyle="Solid"
HorizontalAlign="Left" ForeColor="Black" BackColor="White">
<Padding Left="5px"></Padding>
<BorderDetails ColorTop="DimGray" WidthLeft="0px" WidthTop="0px" ColorLeft="DimGray">
</BorderDetails>
</RowStyleDefault>
<GroupByRowStyleDefault BackColor="Control" BorderColor="Window">
</GroupByRowStyleDefault>
<SelectedRowStyleDefault ForeColor="Black" BackColor="LightSteelBlue">
</SelectedRowStyleDefault>
<GroupByBox Hidden="True">
<BoxStyle BackColor="ActiveBorder" BorderColor="Window">
</BoxStyle>
</GroupByBox>
<AddNewBox>
BorderWidth="1px">
</AddNewBox>
<ActivationObject BorderStyle="None" BorderWidth="0px" AllowActivation="False">
</ActivationObject>
<FilterOptionsDefault>
BorderWidth="1px" CustomRules="overflow:auto;"
Width="200px">
<Padding Left="2px" />
</FilterDropDownStyle>
<FilterHighlightRowStyle BackColor="#151C55" ForeColor="White">
</FilterHighlightRowStyle>
Font-Names="Verdana,Arial,Helvetica,sans-serif" Font-Size="11px">
</FilterOperandDropDownStyle>
</FilterOptionsDefault>
</DisplayLayout>
<Bands>
<igtbl:UltraGridBand>
<Columns>
<igtbl:UltraGridColumn BaseColumnName="ID" Hidden="True">
<Header Caption="ID">
</Header>
</igtbl:UltraGridColumn>
<igtbl:TemplatedColumn Width="5%">
<CellTemplate>
oncheckedchanged="chkSelect_CheckedChanged" AutoPostBack="True" />
</CellTemplate>
<Header Caption="Select">
<RowLayoutColumnInfo OriginX="1" />
<Footer>
</Footer>
</igtbl:TemplatedColumn>
<igtbl:UltraGridColumn AllowUpdate="Yes" BaseColumnName="Code" Width="5%">
<Header Caption="Title">
<RowLayoutColumnInfo OriginX="3" />
<igtbl:UltraGridColumn AllowUpdate="Yes" BaseColumnName="Title" Width="10%">
<Header Caption="Code">
<RowLayoutColumnInfo OriginX="2" />
BaseColumnName="Description" CellMultiline="Yes">
<Header Caption="Description">
<RowLayoutColumnInfo OriginX="6" />
<igtbl:UltraGridColumn AllowUpdate="Yes" BaseColumnName="Sign" Width="5%">
<Header Caption="Sign">
<RowLayoutColumnInfo OriginX="7" />
CellMultiline="Yes" Width="5%">
<Header Caption="Coin">
<RowLayoutColumnInfo OriginX="4" />
BaseColumnName="LeastDecValue">
<Header Caption="Least decimal Val">
<RowLayoutColumnInfo OriginX="5" />
Width="12%">
<Header Caption="Calc. Basis Days">
<RowLayoutColumnInfo OriginX="9" />
<igtbl:UltraGridColumn Width="10%" AllowUpdate="Yes" BaseColumnName="ExchRate">
<Header Caption="Exch. Rate">
<RowLayoutColumnInfo OriginX="8" />
Width="15%">
Enabled="False" oncheckedchanged="chkDefaultCurrency_CheckedChanged" />
<Header Caption="Default Currency">
<RowLayoutColumnInfo OriginX="10" />
</Columns>
<RowEditTemplate>
<div style="padding: 2px; font-size: 8pt; width: 65%; font-family: Verdana; height: 35px; background-color: cornsilk">
Details For Currency:
<div id="tmplName" style="font-weight: bold">
Name</div>
</div>
<table cellspacing="5" cellpadding="0" border="0" style="width: 100%">
border-left: #000000 1px solid; border-bottom: #000000 1px solid">
<table cellspacing="5" cellpadding="0" width="100%" border="0">
<tbody>
<td style="font-size: 8pt; font-family: Verdana" align="left">
Code:<br>
<asp:TextBox ID="TextBox1" runat="server" Font-Size="8pt" Width="190px" columnKey="Code"
Font-Name="Verdana" Font-Names="Verdana" Text='<%# Eval("Code") %>'></asp:TextBox></td>
title:<br>
<asp:TextBox ID="TextBox2" runat="server" Font-Size="8pt" Width="190px" columnKey="Title"
Font-Name="Verdana" Font-Names="Verdana" Text='<%# Eval("Title") %>'></asp:TextBox></td>
Sign:<br>
<asp:TextBox ID="TextBox3" runat="server" Font-Size="8pt" Width="190px" columnKey="Sign"
Font-Name="Verdana" Font-Names="Verdana" Text='<%# Eval("Sign") %>'></asp:TextBox></td>
</table>
<table cellspacing="5" cellpadding="0" border="0">
<td style="font-size: 8pt; font-family: Verdana" align="right">
Coin:</td>
Text='<%# Eval("Coin") %>'></asp:TextBox>
<td style="font-size: 8pt; font-family: Verdana" valign="top" align="right">
Description:</td>
TextMode="MultiLine"></asp:TextBox>
Ship City:</td>
<input style="font-size: 8pt; width: 125px; font-family: Verdana" type="text" size="22"
columnkey="ShipCity">
Ship region:</td>
<input style="font-size: 8pt; width: 125px; font-family: Verdana" type="text" size="10"
columnkey="ShipRegion">
Ship Postal Code:</td>
columnkey="ShipPostalCode">
Ship Country:</td>
columnkey="ShipCountry">
<caption>
<br>
background-color: lightsteelblue" type="button" value="OK">
background-color: darkseagreen" type="button" value="Cancel">
</caption>
</RowEditTemplate>
<RowTemplateStyle BackColor="Window" BorderColor="Window" BorderStyle="Ridge">
WidthTop="3px" />
</RowTemplateStyle>
<AddNewRow View="NotSet" Visible="NotSet">
</AddNewRow>
</igtbl:UltraGridBand>
</Bands>
</igtbl:UltraWebGrid>
</igtab:Tab>
<igtab:Tab Text="Arabic" Tooltip="Enter Data in Arabic Language">
Width="325px">
<bands>
<addnewrow view="NotSet" visible="NotSet">
</addnewrow>
</bands>
allowdeletedefault="Yes" allowsortingdefault="OnClient"
headerclickactiondefault="SortMulti" name="UltraWebGrid1"
selecttyperowdefault="Extended" stationarymargins="Header"
viewtype="OutlookGroupBy">
font-size="8.25pt" height="200px" width="325px">
</framestyle>
<pager minimumpagesfordisplay="2">
widthtop="1px" />
</pager>
<editcellstyledefault borderstyle="None" borderwidth="0px">
</editcellstyledefault>
<footerstyledefault backcolor="LightGray" borderstyle="Solid" borderwidth="1px">
</footerstyledefault>
horizontalalign="Left">
</headerstyledefault>
borderwidth="1px" font-names="Microsoft Sans Serif" font-size="8.25pt">
<padding left="3px" />
<borderdetails colorleft="Window" colortop="Window" />
</rowstyledefault>
<groupbyrowstyledefault backcolor="Control" bordercolor="Window">
</groupbyrowstyledefault>
<groupbybox>
<boxstyle backcolor="ActiveBorder" bordercolor="Window">
</boxstyle>
</groupbybox>
<addnewbox hidden="False">
borderwidth="1px">
</addnewbox>
<activationobject bordercolor="" borderwidth="">
</activationobject>
<filteroptionsdefault>
borderwidth="1px" customrules="overflow:auto;"
width="200px">
<padding left="2px" />
</filterdropdownstyle>
<filterhighlightrowstyle backcolor="#151C55" forecolor="White">
</filterhighlightrowstyle>
font-names="Verdana,Arial,Helvetica,sans-serif" font-size="11px">
</filteroperanddropdownstyle>
</filteroptionsdefault>
</displaylayout>
</Tabs>
</igtab:UltraWebTab>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnAddNewAbove" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="btnDeleteAbove" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="btnAddNewBelow" />
<asp:AsyncPostBackTrigger ControlID="btnDeleteBelow" />
</Triggers>
<td style="height: 82px">
<td colspan="4" style="height: 30px">
<td style="height: 30px">
<asp:UpdatePanel ID="UpdatePanel3" runat="server">
<td colspan="2">
Hello,
I was able to reproduce the same problem locally. It seems that if you are manually binding the grid (e.g. not using declarative datasources), you need to bind the grid very early in the page life-cycle in order to avoid the exception you are getting - you need to re-bind the grid in the Page_Init (OnInit event of the Page) event handler. You can also try using the InitializeDataSource event of the grid - it gets automatically called when datasource is needed and my actually be the better solution. Moving my binding code to OnInit solved the problem in my case, hopefully this approach is applicable in your case as well, or you can try InitializeDataSource as well.
You can find a related thread with this and other suggestions that helped here:
http://forums.infragistics.com/forums/p/3026/17064.aspx
I also recommend the following blog post for additional information how databinding in UltraWebGrid works in general:
http://blogs.infragistics.com/blogs/tony_lombardo/archive/2008/01/29/demystifying-infragistics-webgrid-databinding.aspx
Thanx Rumen Stankov
Still i m not able to solve my problem. I have used object Data source now. But still same problem. Here is my new code:
//this.BindGridData();
//this.BindGridData
protected void grdEnglishCurrencies_InitializeDataSource(object sender, UltraGridEventArgs e)
I think I know what is going on - you will probably need to explicitly rebind the grid after you set the DataSourceID property. DataSourceID is just a strig property and does not initiate rebinding automatically - binding is delayed up until the OnPrender method.
So I believe if you change your code to explicitly call DataBind() after setting DataSourceID, things will work fine. Example:
this.grdEnglishCurrencies.DataSourceID = "ObjectDataSource1";this.grdEnglishCurrencies.DataBind();
Rumen Stankov"] So I believe if you change your code to explicitly call DataBind() after setting DataSourceID, things will work fine. Example: this.grdEnglishCurrencies.DataSourceID = "ObjectDataSource1";this.grdEnglishCurrencies.DataBind();
Still i m getting same error. No Effect !!!!!!!!!!