Formatting a programatically created column..

eaohen

New member
Joined
Oct 19, 2009
Messages
2
Programming Experience
1-3
Hello Everyone I have a question that maybe somebody can help me with:

I am trying to figure out the best way to format a column created at runtime.

of course naturally the following code doesnt work:

Dim dcFutureViews As New DataColumn("Totals", GetType(String))
dcFutureViews.Expression = String.Format("CountofS / SUM(CountofS)", "{0:c}")

tbl3.Columns.Add(dcFutureViews)[/
B]

Does anyone have any ideas?

Also one more question:
i want to be able to get the sum of a column and display that information in the footer for each column I have attached my code let me know what you guys think.



Dim connectionString As String = ConfigurationManager.ConnectionStrings("prodigy_testConnectionString").ConnectionString
conn As New OleDbConnection(connectionString)
If conn.State = ConnectionState.Closed Then
conn.Open()
End If

Dim cmd As New OleDbCommand("select * from tbl_Houston order by screenvendor", conn)
Dim cmd1 As New OleDbCommand("Select * from tbl_Easttexas", conn)
Dim ShakerCmd As New OleDbCommand("SELECT ShakerVendor, COUNT(ShakerVendor) AS CountOfS FROM tbl_houston WHERE ShakerVendor IS NOT NULL Group By ShakerVendor", conn)


Dim adp As New OleDbDataAdapter(cmd)
Dim adp1 As New OleDbDataAdapter(cmd1)
Dim adp2 As New OleDbDataAdapter(ShakerCmd)

Dim dset As New DataSet()


adp.Fill(dset, "First Table")
adp1.Fill(dset, "Second Table")
adp2.Fill(dset, "Third Table")


If conn.State = ConnectionState.Open Then
conn.Close()
End If


Dim tbl1 As DataTable = dset.Tables(0)
Dim tbl2 As DataTable = dset.Tables(1)
Dim tbl3 As DataTable = dset.Tables(2)

Dim dcFutureViews As New DataColumn("Totals", GetType(String))
dcFutureViews.Expression = String.Format("CountofS / SUM(CountofS)", "{0:c}")


tbl3.Columns.Add(dcFutureViews)


Dim rows As New DataView(tbl1)
rows.RowFilter = "S = 'D'"


GridView6.DataSource = tbl3
GridView6.DataBind()
 
Top Bottom