how can I get real value in datagrid column instead of 'System.Data.DataRowView'

2 posts, 0 answers
  1. Bashabi
    Bashabi avatar
    1 posts
    Member since:
    May 2016

    Posted 17 May Link to this post

    This was the previous code in aspx file (done by previous developer)

     

      <radG:RadGrid ID="uxUsers" runat="server" RadControlsDir="~/RadControls/" AllowPaging="False"  HorizontalAlign="NotSet">        
            <MasterTableView AllowMultiColumnSorting="True" AllowSorting="True" ShowFooter="False" AutoGenerateColumns="False">           
                <Columns>
                    <radG:GridBoundColumn DataField="name" HeaderText="Name" ReadOnly="True" UniqueName="name" />        
                    <radG:GridBoundColumn DataField="email" HeaderText="Email" ReadOnly="True" UniqueName="email" /> 
                   </Columns>
            </MasterTableView>
        </radG:RadGrid>

     

    and the code behind it is 

      Private Sub BindEmployerUsers()
            uxUsers.DataSource = DB.GetData("SELECT eu.id, u.email, u.name + ' ' + u.surname AS name, CASE WHEN u.emailverified IS NULL THEN 'No' ELSE 'Yes' END AS emailverified, u.active FROM EmployerUser eu INNER JOIN [User] u ON eu.userid = u.id WHERE u.deleted = 0 AND  eu.employerid = " & Employer.ID)
            uxUsers.DataBind()
        End Sub

     

     

    That was working fine. now i have added another column 

     

     <radG:RadGrid ID="uxUsers" runat="server" RadControlsDir="~/RadControls/" AllowPaging="False"  HorizontalAlign="NotSet">        
            <MasterTableView AllowMultiColumnSorting="True" AllowSorting="True" ShowFooter="False" AutoGenerateColumns="False">           
                <Columns>
                    <radG:GridBoundColumn DataField="name" HeaderText="Name" ReadOnly="True" UniqueName="name" />        
                    <radG:GridBoundColumn DataField="email" HeaderText="Email" ReadOnly="True" UniqueName="email" /> 
                    <radG:GridBoundColumn DataField="primaruser" HeaderText="PrimarUser" ReadOnly="True" UniqueName="PrimarUser" /> 

                  </Columns>
            </MasterTableView>
        </radG:RadGrid>

     

    and the code behind this is 

     

        Private Sub BindEmployerUsers()
            uxUsers.DataSource = DB.GetData("SELECT  eu.id, u.email, u.name + ' ' + u.surname AS name,  CASE WHEN eu.id=e.primaryemployeruserid  THEN 'yes' ELSE 'No' END AS PrimaryUser, CASE WHEN u.emailverified IS NULL THEN 'No' ELSE 'Yes' END AS emailverified, u.active FROM Employer e INNER JOIN EmployerUser eu on e.id=eu.employerid INNER JOIN [User] u ON eu.userid = u.id WHERE u.deleted = 0 AND  eu.employerid = " & Employer.ID)
            uxUsers.DataBind()

        End Sub

     

    but i get 'System.Data.DataRowView instead of real value.

     

    how to fix this

  2. Viktor Tachev
    Admin
    Viktor Tachev avatar
    1488 posts

    Posted 19 May Link to this post

    Hello Bashabi,

    I have examined the code and noticed that the DataField property for the new column does not correspond to the field returned by the database query.

    The DataField points to primaruser and the field in the Select statement is called PrimaryUser. Note that there is a 'y' missing in the first and the case is different. Make sure that the two strings match exactly and see how the behavior changes.

    Regards,
    Viktor Tachev
    Telerik
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top