Link to home
Create AccountLog in
Avatar of NickMalloy
NickMalloyFlag for United States of America

asked on

e.row.dataitem is null

I am trying to do some code in my rowevent for a gridview, but I keep getting null values and I can't figure out what I am missing??  Here is my code

 <asp:GridView ID="GridView2" AllowPaging="True" AllowSorting="true" DataSourceID="EntityDataSource1"
                                    Width="100%" Font-Size="X-Small" AutoGenerateColumns="false"
                                    runat="server" DataKeyNames="AskQuestionID" OnPageIndexChanging="GridView2_PageIndexChanging"
                                    OnRowUpdating="GridView2_RowUpdating" OnRowCommand="GridView2_RowCommand" OnRowEditing="GridView2_RowEditing"
                                    GridLines="None" OnRowUpdated="GridView2_RowUpdated" OnRowCancelingEdit="GridView2_CancelingEdit"
                                    OnRowDataBound="GridView2_RowDataBound" OnRowDeleting="GridView2_RowDeleting"
                                    OnRowDeleted="GridView2_RowDeleted" OnSorting="GridView2_Sorting">
                                    <RowStyle BackColor="Gainsboro" />
                                    <AlternatingRowStyle BackColor="#cccccc" />
                                    <Columns>
           
                                        <asp:TemplateField HeaderText="Question ID" SortExpression="AskQuestionID">
                                            <ItemTemplate>
                                                <asp:Label ID="lblOrderID" Text='<%# Eval("AskQuestionID") %>' runat="server"></asp:Label>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                       
                                     <asp:TemplateField HeaderText="View Record">
                <ItemTemplate>          
                    <asp:LinkButton ID="ReassignButton" runat="server" CommandName="ViewAs" CommandArgument="<%# ((GridViewRow) Container).RowIndex %>"
                        Text="View Record" />
                    <br />
                </ItemTemplate>
                  </asp:TemplateField>
                                    </Columns>
                                </asp:GridView>

<asp:EntityDataSource ID="EntityDataSource1" runat="server"
            ConnectionString="name=MyQEntities" DefaultContainerName="MyQEntities"
            EnableDelete="True" EnableFlattening="False" EntitySetName="vw_NestedUI">
          </asp:EntityDataSource>

 protected void GridView2_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        //Check if this is our Blank Row being databound, if so make the row invisible
        if (e.Row.RowType == DataControlRowType.DataRow)
        {

            ICustomTypeDescriptor descriptor = e.Row.DataItem as ICustomTypeDescriptor;

            if (null != descriptor)
            {

}

}
Avatar of Tom Beck
Tom Beck
Flag of United States of America image

There's a } missing, or is that just a cut and paste error.
Avatar of NickMalloy

ASKER

cut paste error.
ASKER CERTIFIED SOLUTION
Avatar of Tom Beck
Tom Beck
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer