I want to display data in my own format from Mysql database connecting through ASP.NET.
Currently I’m using MySQLDataGrid to display values in table format.
My code is
myConnection = New MySqlConnection("server=localhost; user id=root; password=''; database=test; pooling=false;")
strSQL = "SELECT * FROM tablename;"
myDataAdapter = New MySqlDataAdapter(strSQL, myConnection)
myDataSet = New Dataset()
myDataAdapter.Fill(myDataSet, "mytable")
MySQLDataGrid.DataSource = myDataSet
MySQLDataGrid.DataBind()
and asp code is:
<asp:DataGrid id="MySQLDataGrid" runat="server" />
its displaying all columns in Grid format.
But i actually wanted to display in HTML table format with some included/exclude fields. like below.
UserName :
City :
Address:
etc…
Can I have a simple example code on how to do it?
By default, columns are auto-generated corresponding to the binded datasource. You can disable this with the property AutoGenerateColumns by setting it to False:
Then you can define yourself the columns you’d like to show under the
<columns/>tagThere a few types of columns:
The documentation page for the DataGrid show a bunch of example on how to use the different types of columns (button columns, add a checkbox…)