ASP.net VB.net use code to bind a GridView templatre column

Murray Brown
Murray Brown used Ask the Experts™
on
Hi
I have the following two ASP.net GridVidew template columns
The first binds to EmloyeeName but the second has to bind to various
other columns. What VB.net code would I use to bind that column programatically?

              <asp:TemplateField HeaderText="Employee Name" Visible="true">
                           <ItemTemplate>
                                <asp:Label ID="lblEmployeeName" runat="server" Text='<%# Bind("EmployeeName")%>' Visible="true"></asp:Label>
                           </ItemTemplate>
                      </asp:TemplateField>
                      <asp:TemplateField HeaderText="T2" Visible="true">
                           <ItemTemplate>
                                <asp:Textbox ID="T2" runat="server"  Visible="true" Width="10"></asp:Textbox>
                           </ItemTemplate>
                      </asp:TemplateField>

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Chief Technology Ninja
Distinguished Expert 2018
Commented:
Hi Murray,

Based on the datatype and control you are targeting (Textbox, checkbox, radio) there are different attributes you will have to bind. Here it is a Textbox hence we will bind Text property. Please refer to: https://docs.microsoft.com/en-us/dotnet/api/system.web.ui.webcontrols.textbox?view=netframework-4.8

<asp:Textbox ID="T2" runat="server" Text='<%# Bind("SecondColumnName")%>' Visible="true" Width="10"></asp:Textbox>

Open in new window


Regards,
Chinmay.
Murray BrownASP.net/VSTO Developer

Author

Commented:
Thanks very much

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial