locked
Setting DataField Value Equal to DataTable Column Index RRS feed

  • Question

  • User1231829591 posted

    Hi All , the following is a markup of a BoundField in a Gridview on one of my web pages.

    <asp:BoundField HeaderStyle-HorizontalAlign="Left" HeaderStyle-Font-Bold="false"
          HeaderStyle-VerticalAlign="Middle" HeaderText="Title" 
    DataField="BOOK_TITLE" ItemStyle-CssClass="right_Cell"> </asp:BoundField>

    The Gridview is bound to a DataTable object. Is there a way to set the DataField attribute equal to

    the index of a column of the DataTable instead of the name of a column? So instead of setting

    DataField = "Book_Title", set it equal to the index of the the Book_Title column in the Datatable.

    Thanks in advance.

    Tuesday, February 24, 2015 10:10 PM

Answers