Still Trying!!!! Thanks to all who have helped before but I'm still not quite getting there.
Still trying to build my grid in code. Still trying to modify the format of the date fields (they always display Time portions)
I've found that a DataFormatString of "{0:d}" will properly format a field.
At the moment, my problem is actually assigning the value. Here's what I have so far
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim tvPage1 As TreeView = CType(Session("treeview"), TreeView)
Dim strConn As String = CType(Me.Master, MasterPage).connectString
Dim objConn As New MySqlConnection(strConn)
Dim objDS As New DataSet
Dim ldDate As String = (CType(ddlDates.SelectedValue, Date).GetDateTimeFormats())(66)
Dim strSql As String
strSql = "SELECT action,totNumberActions,Status,totCountStatus,categoryname,savedate,auditdate " & _
" FROM kpi_mrpactions " & _
" WHERE savedate = '" & ldDate & "'" & _
" ORDER BY action,status "
Dim daMrp As New MySqlDataAdapter(strSql, objConn)
daMrp.Fill(objDS, "dtMrp")
GridView1.DataSource = objDS
GridView1.DataBind()
Question 1: Is there a problem with the code so far? When the page renders, the grid displays the correct data.
Question 2: How can I reference the correct column to set the DataFormatString? I've tried looking at the columns collection, but the count is 0 and any attempt to reference Columns(i) results in an "Index out of range" error.
Have I missed a step in creating the grid? Is there some property which needs to be set?
As to why I'm not using a DataSource..............
1. I'm stubborn and want to learn how to do this in code.
2. The eventual idea is to have the user pick the table/fields to be displayed and I want to be able to build my code around the selections.
All help greatly appreciated...............Rich