locked
Type 'System.Web.UI.WebControls.DataGrid' does not have a property named 'span'. RRS feed

  • Question

  • User456747025 posted

    trying to implement a second data table into my website, using pretty much the same code and i get this error for the second table

    <span class="menutitle">STAFF PERMISSIONS</span><br />
    <asp:datagrid id="dgResultsPerms" datakeyfield="IntroCommID" runat="server" autogeneratecolumns="False"
    showheader="True" showfooter="false" gridlines="Both" cssclass="copy" headerstyle-backcolor="#999999"
    alternatingitemstyle-backcolor="#fafafa" align="center" headerstyle-height="25"
    headerstyle-cssclass="menu" alternatingitemstyle-verticalalign="Top" width="90%"
    itemstyle-verticalalign="Top" onitemdatabound="dgResultsIntro_EachRow">
    <Columns>
    <asp:BoundColumn HeaderText="ID" DataField="IntroCommID" ReadOnly="True" Visible="false"/>
    <asp:BoundColumn HeaderText="Introducer" DataField="IntroducerName" ReadOnly="True" Visible="false"/>
    <asp:TemplateColumn ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center" HeaderText="Introducer" >
    <ItemTemplate>
    <asp:TextBox ID="tb_IntName" runat="server" width="250px"></asp:TextBox>
    </ItemTemplate>
    </asp:TemplateColumn>
    <asp:BoundColumn HeaderText="Introducer<br>Fixed &pound;" DataField="IntroCommFixed" ReadOnly="True" Visible="false"/>
    <asp:TemplateColumn ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center" HeaderText="Introducer<br>Fixed &pound;" >
    <ItemTemplate>
    <asp:TextBox ID="tb_IntroFixed" runat="server" width="60px"></asp:TextBox>
    </ItemTemplate>
    </asp:TemplateColumn>
    <asp:BoundColumn HeaderText="Introducer<br>% of Net" DataField="IntroCommPercent" ReadOnly="True" Visible="false"/>
    <asp:TemplateColumn ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center" HeaderText="Introducer<br>% of Net" >
    <ItemTemplate>
    <asp:TextBox ID="tb_IntroPercent" runat="server" width="60px"></asp:TextBox>
    </ItemTemplate>
    </asp:TemplateColumn>
    <asp:TemplateColumn ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center">
    <HeaderTemplate>Delete?</HeaderTemplate>
    <ItemTemplate> <asp:CheckBox ID="chkDelete" runat="server" /></ItemTemplate>
    </asp:TemplateColumn>
    </Columns>

    Thursday, July 11, 2019 10:54 AM

All replies

  • User1564875471 posted

    Did you forget close the asp:datagrid tag ? </asp:datagrid>

    In addition, Please use asp:gridview as the asp:datagrid is an old control which was introduced in ASP.NET 1.0 and replaced by the asp:datagrid in ASP.NET 2.0

    Thursday, July 11, 2019 6:21 PM
  • User665608656 posted

    Hi juxt4posed,

    According to your code, I'm not sure if the code you gave me is complete.

    To test with so much code you've given, as anas says, you should be missing the end tag of datagrid.

    If you still have errors, please provide us with your detailed code.

    I've changed your code to the GridView format in the new version for your reference:

                <span class="menutitle">STAFF PERMISSIONS</span><br />
                <asp:GridView ID="GridView1" runat="server" DataKeyField="IntroCommID" AutoGenerateColumns="False"
                    ShowHeader="True" ShowFooter="false" GridLines="Both" CssClass="copy" HeaderStyle-BackColor="#999999"
                    AlternatingItemStyle-BackColor="#fafafa" align="center" HeaderStyle-Height="25"
                    HeaderStyle-CssClass="menu" AlternatingItemStyle-VerticalAlign="Top" Width="90%"
                    ItemStyle-VerticalAlign="Top" OnDataBound="GridView1_DataBound">
                    <Columns>
                        <asp:BoundField HeaderText="ID" DataField="IntroCommID" ReadOnly="True" Visible="false" />
                        <asp:BoundField HeaderText="Introducer" DataField="IntroducerName" ReadOnly="True" Visible="false" />
                        <asp:TemplateField ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center" HeaderText="Introducer">
                            <ItemTemplate>
                                <asp:TextBox ID="tb_IntName" runat="server" Width="250px" ></asp:TextBox>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:BoundField HeaderText="Introducer<br>Fixed &pound;" DataField="IntroCommFixed" ReadOnly="True" Visible="false" />
                        <asp:TemplateField ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center" HeaderText="Introducer<br>Fixed &pound;">
                            <ItemTemplate>
                                <asp:TextBox ID="tb_IntroFixed" runat="server" Width="60px" ></asp:TextBox>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:BoundField HeaderText="Introducer<br>% of Net" DataField="IntroCommPercent" ReadOnly="True" Visible="false" />
                        <asp:TemplateField ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center" HeaderText="Introducer<br>% of Net">
                            <ItemTemplate>
                                <asp:TextBox ID="tb_IntroPercent" runat="server" Width="60px"></asp:TextBox>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center">
                            <HeaderTemplate>Delete?</HeaderTemplate>
                            <ItemTemplate>
                                <asp:CheckBox ID="chkDelete" runat="server" />
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Columns>
                </asp:GridView>
    

    The result of this work demo:

    Best Regards,

    YongQing.

    Friday, July 12, 2019 3:28 AM