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!
| | | | Download a free trial version of IBM DB2 9.5 for Linux, UNIX, and Windows. DB2 9 is the result of a five-year development project that transformed traditional (static) database technology into an interactive data server that merges the high performance and ease of use of DB2 with the self-describing benefits of XML. FREE! Go There Now!
| | | | Visit IBM developerWorks to download the latest trial version of IBM Data Studio V1.1 at no cost. IBM Data Studio is a comprehensive data management solution that helps you effectively design, develop, deploy and manage your data, databases, and database applications throughout the data management life cycle utilizing a consistent and integrated user interface. Unlike other client-side data management solutions that focus on only one aspect of the application lifecycle or database administration, Data Studio complements the Rational Software Delivery platform, providing unparalleled flexibility for a heterogeneous data server environment across platforms. FREE! Go There Now!
| | | | Ken Krugler, co-founder of code search company Krugle, and Laura Merling, vice president of Marketing and Business Development for Krugle, join to talk about the ins and outs of code search and what it means as a new feature for developerWorks users. FREE! Go There Now!
| | | | This webcast outlines the best practices that must be instituted to gain the maximum benefit from SOA while maintaining high quality of service. Whether you are deploying new applications or managing and monitoring your existing infrastructure, learn how you can ensure high quality of services with SOA based solutions from IBM. All registrants who attend this live Web Seminar will receive complimentary access to a white paper titled “Maintaining QoS in an SOA Environment”. FREE! Go There Now!
| | | | Rational Build Forge Express Edition is an automation framework that packages the latest enterprise-grade technologies into a reliable, flexible and robust configuration designed and priced specifically for small to midsize businesses. The new Rational Build Forge Express eKit provides you with valuable resources – including a case study, podcast, demo, and articles – to help you increase staff productivity, compress development cycles and deliver better software, fast. FREE! Go There Now!
| | | | Discover how Rational tools and best practices for testing can make your job easier. The new Rational Testing eKits provide you with valuable resources – including demos, webcasts, tutorials, and articles – that help you address your specific testing needs across the software lifecycle. Five new eKits are available covering the topics of Requirements and Test Management, Functional Testing, Performance Testing, Code Quality and Embedded Systems, and SOA and Web Services Testing. FREE! Go There Now!
| | | | This whitepaper provides areas to consider when evaluating any software configuration management solution. It addresses how the IBM solutions (Rational ClearCase and Rational ClearQuest) meet the needs and requirements of both project leaders and developers to provide successful Software Change and Configuration Management. FREE! Go There Now!
| | | | Get a free trial download of the latest version of IBM Rational Tester for SOA Quality V7.0.1, a functional and regression testing tool that enables the creation, comprehension, modification and execution of testing GUI-less Web services. FREE! Go There Now!
| | | | Join this webcast to learn how IBM Rational's Functional Testing solution enables you to implement automation your way, at your pace, with your existing staff. In this webcast, you’ll learn how you can eliminate redundancy of manual test scripts, reduce errors, and increase test coverage through test automation. After this presentation you will understand how IBM Rational Functional Testing solution can streamline your manual testing and make test automation easily attainable. FREE! Go There Now!
| | | | All FREE IBM® developerWorks Tools! | |