How to Merge Columns in DataGrid

Merging columns can be beneficial, such as having columns for a first and last name to show a full name of your customer. You accomplish this by tweaking the HTML tags in your coding file. When the DataGrid is printed to the web screen, the HTML is laid out by your code. You edit this code to merge columns and combine them together.

Instructions

    • 1

      Click the Windows "Start" button and select "Programs." Click "Microsoft .NET Framework," then click "Visual Studio." Click your project name in the splash screen to open your coding files.

    • 2

      Double-click the form that contains your DataGrid. When the form opens, double-click the DataGrid to point your cursor to the DataGrid section of your code file.

    • 3

      Type the following code to merge your files:

      e.Item.Cells(0).ColumnSpan = 2

      e.Item.Cells(0).Text = "<table ><td colspan=2>Name</td></tr><tr align =center ><td>First Name</td><td>Last Name</td></tr></table>"

    • 4

      Click "Run" at the top of your Visual Studio window. The "Run" button lets you see the DataGrid code changes in your web browser.

Related Searches:

References

Comments

You May Also Like

Related Ads

Featured