What property do we require to add within the Gridview tags to bind columns manually?

 Posted by vishalneeraj-24503 on 1/14/2014 | Category: ASP.NET Interview questions | Views: 727 | Points: 40
Answer:

We have to set AutoGenerateColumns Property to false on the Gridview to bind columns manually.In such case,we have to write code inside TemplateField or BoundField.

<asp:GridView ID="grid_employee_details" runat="server" AutoGenerateColumns="false">

<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Label ID="lbl_employee_full_name" runat="server" Text='<%#eval("first_name") & " " & eval("last_name") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>

<asp:BoundField HeaderText="Employee Name" DataField = "middle_name" NullDisplayText="Not Found" />
</Columns>
</asp:GridView>


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response