Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2014-01-06
2
Medium Priority
?
656 Views
Last Modified: 2014-01-06
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
Comment
Question by:Murray Brown
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 2000 total points
ID: 39758981
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
 

Author Closing Comment

by:Murray Brown
ID: 39759034
Thanks very much. Appreciate it!
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question