Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
500
Is it a bug use <%#Eval("field")%> in UltraWebGrid?
posted

the webgrid add a TemplatedColumn like this

 <igtbl:TemplatedColumn>
            <CellTemplate>
          <a  href="#" onclick="BLOCKED SCRIPTalert(<%#Eval("id")%>);">test</a>
            </CellTemplate>
        </igtbl:TemplatedColumn>

 the webgrid first databind is ok.but if it postback then show the error in  <%#Eval("id")%>):

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Why?

  • 28464
    Verified Answer
    posted

    Hello,

    This syntax is perfectly valid and supported. The reason for the problem you are getting is most probably related to the fact that somehow the grid is not bound with data on postback. Where are you populating the grid with data? I strongly recommend doing that in the InitializeDataSource event of the grid - this event gets called automatically when the grid needs data.

     I can also recommend this blog post for detailed information how UltraWebGrid's databinding works:

    http://blogs.infragistics.com/blogs/tony_lombardo/archive/2008/01/29/demystifying-infragistics-webgrid-databinding.aspx

    Hope this helps.