A sample code to Add two DataTables in a datagrid using bound columns? Create a main Page (Drag and drop Datagrid on the design view ) ? Change the Datagrid Autogenerate Property = false) ? The demonstartion creates a Datagrid Bound Columns dynamically and add two datatables to one datagrid[bold]Step 1: main.aspx[/bold]
<!asp:DataGrid id="DataGrid1" style="Z-INDEX: 102; LEFT: 278px; POSITION: absolute; TOP: 81px" runat="server" AutoGenerateColumns="false ...A sample code to Add two DataTables in a datagrid using bound columns
? Create a main Page (Drag and drop Datagrid on the design view ) ? Change the Datagrid Autogenerate Property = false) ? The demonstartion creates a Datagrid Bound Columns dynamically and add two datatables to one datagrid
[bold]Step 1: main.aspx[/bold] [code] <asp:DataGrid id="DataGrid1" style="Z-INDEX: 102; LEFT: 278px; POSITION: absolute; TOP: 81px" runat="server" AutoGenerateColumns="false"></asp:DataGrid>
[bold]Step 2: main.aspx.vb [/bold]
Try
Dim mycn As New System.Data.SQLClient.SqlConnection("server=localhost;uid=sa;password=;database=northwind;")
Dim myda As New System.Data.SQLClient.SqlDataAdapter("Select productid,categoryid,productname from Products ", mycn)
Dim myda1 As New System.Data.SQLClient.SqlDataAdapter("Select categoryid from Categories ", mycn)
Dim ds As New System.Data.DataSet()
myda.Fill(ds, "Products")
myda1.Fill(ds, "Categories")
Dim objbc As BoundColumn
Dim dc As DataColumn
Dim dt As DataTable
For Each dt In ds.Tables
For Each dc In dt.Columns
objbc = New BoundColumn()
objbc.HeaderText = dc.ColumnName
objbc.DataField = dc.ColumnName
DataGrid1.Columns.Add(objbc)
Next
Next
DataGrid1.DataSource = ds.Tables(0)
DataGrid1.DataBind()
Catch ex As Exception
Response.Write(ex.Message & ex.StackTrace)
End Try
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |
More ASP.NET Code Articles More By aspfree developerWorks - FREE Tools! | Achieving true agility is a never-ending effort. We will showcase how you can become agile incrementally, a few practices at the time.Which practices should any agile team strive to adopt? What additional practices should you consider based on your needs to scale? Adopting practices are however made much easier with the right tool support. What about if your tools adapt to your practices? We will take a look at how the Jazz technology can be leveraged to make your process change the behavior of your tools. FREE! Go There Now!
| | | | Building a software-as-a-service solution requires addressing a few key technical challenges. In this webcast, we'll focus on the role of IBM Tivoli Directory Server and WebSphere Portlet Factory in creating a Software as a Service solution. We will demonstrate how to use Tivoli Directory Server to prevent the user population of one tenant from accessing the virtual portal and portlet components of another tenant. We will also use the dynamic profile capability of WebSphere Portlet Factory to create multiple highly customized applications from one code base. FREE! Go There Now!
| | | | In this five-part "Building a grid system using WS-Resource Transfer" series, we look at the use of WS-Resource Transfer (WS-RT) in different areas of the grid environment -- from using it as a method for storing and recovering general information about grid-to-grid monitoring and management, and security. We also examine how WS-RT can be used for the distribution and division of work. In any grid, there is a huge amount of metadata about the grid that needs to be stored and distributed. Using WS-RT makes sharing the information, especially the precise information required by different systems in the grid, significantly easier. Here in Part 4, we look at both sides of the security session, both in terms of using WS-RT as an aid to the authorization process and at combining WS-Security with WS-RT for secure resource exchange. FREE! Go There Now!
| | | | CakePHP is a stable production-ready, rapid-development aid for building Web sites in PHP. This "Cook up Web sites fast with CakePHP" series shows you how to build an online product catalog using CakePHP. FREE! Go There Now!
| | | | Learn how you can extend modern application lifecycle management to IBM System z through the IBM Rational Software Delivery Platform (SDP). The Did you say mainframe? e-kit includes podcasts, webcasts, tutorials, white and red papers, demos, and articles designed to help ease the challenges of modernizing your enterprise. This complimentary kit for mainframe developers is a practical, how-to guide for making the most of an existing development environment, including the skills and infrastructure already in place at an established enterprise. FREE! Go There Now!
| | | | Download the Rational Application Developer (RAD) v7.5 open beta code and start developing applications for the JEE5 standard which features EJB3.0, JPA, JSF 1.2, JSP 2.1 and Servlet 2.5 standards. When you use this beta you will see how you can increase developer productivity for already existing applications with improved support for refactoring, as well as adding new features to existing applications. In addition, the beta provides tooling for JD Edwards, Oracle, SAP, Siebel and PeopleSoft to improve the developer productivity with these enterprise systems. FREE! Go There Now!
| | | | IBM DB2 9.5 provides new options for tighter security, and allows for more granularity and flexibility in administration of the database. This tutorial is the second of two tutorials that cover roles and trusted contexts. Follow the exercises in this tutorial, and learn how to take advantage of the new DB2 feature trusted contexts in combination with other essential e-business technologies such as Web services, Web application server, and DB2 database server. FREE! Go There Now!
| | | | Asset Reuse is a key strategy for companies looking to create innovative solutions to solve complex software development problems. Searching for, identifying, updating, using and deploying software assets can be a difficult challenge. Listen to this webcast, to learn about strategies and tools that you can leverage for a successful project, including Rational Asset Manager, Rational Software Architect and WebSphere Service Registry and Repository. FREE! Go There Now!
| | | | Here's a fun way to learn about DB2! Learn or teach the basics of DB2 and relational database with an interactive game called The DB2 Detective Game. The game teaches relational database concepts and shows how technology can be applied to solving real-life problems (the game's theme is a crime investigation). This tutorial has been updated for DB2 9. FREE! Go There Now!
| | | | Try the latest version of IBM Rational Manual Tester V7.0.1 by downloading a free trial from IBM developerWorks. This manual test authoring and execution tool promotes test step reuse to reduce the impact of software change on testers and business analysts and addresses the needs of teams performing at least a portion of their testing manually. FREE! Go There Now!
| | | | All FREE IBM® developerWorks Tools! | |