Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 678
  • Last Modified:

ASP.net bound GridView and manually add a set of asp:BoundFields

In a bound ASP.net GridView how do you set AutoGenerateColumns to false and manually add a set of asp:BoundFields for your SQL columns rather than letting them be generated automatically.
0
Murray Brown
Asked:
Murray Brown
1 Solution
 
Carl TawnSystems and Integration DeveloperCommented:
Simplisticly it would be something like the following:
        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false">
            <Columns>
                <!-- These will be bound to fields in the data source -->
                <asp:BoundField DataField="Product_Name" />
                <asp:BoundField DataField="Description" />
                <!-- These are custom fields -->
                <asp:TemplateField>
                    <ItemTemplate>
                        <asp:RadioButtonList ID="Radio1" runat="server">
                            <asp:ListItem Value="1" Text="Yes" />
                            <asp:ListItem Value="0" Text="No" />
                        </asp:RadioButtonList>
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
        </asp:GridView>

Open in new window

Note the AutoGenerateColumns="false" in the definition of the GridView. The first two columns will bind to fields in you SQL Statement/data source, the TemplateField is independent of the data source.
0
 
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
Thanks very much. Appreciate it!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now