Good Day !
usually datagrid only display data directly from the database.
this is how i usually did it :
Quote:
Private Sub FillGrid()
Dim oConn As SqlConnection oConn = New SqlConnection(ConfigurationSettings.AppSettings("S MPBDB"))
Filtering()
Dim sqldataAdapter1 As SqlDataAdapter = New SqlDataAdapter(Session("mySelectQuery"), ConfigurationSettings.AppSettings("SMPBDB"))
Dim dsSchedule As DataSet = New DataSet sqldataAdapter1.Fill(dsSchedule)
dgUser.DataSource = dsSchedule
dgUser.DataBind()
oConn.Close()
End Sub
|
pass it into --->
Quote:
PrivateSub Filtering()
Dim SelectQry, mySelectQuery AsString
SelectQry = "SELECT * FROM Rekod_Kursus INNER JOIN SenaraiPeserta ON Rekod_Kursus.NoRujukan = SenaraiPeserta.NoRujukan"
Dim ThnMula AsString = Trim(ddlThnMula.SelectedValue)
If (ThnMula <> "Semua") Then
mySelectQuery = SelectQry & " where Rekod_Kursus.ThnMula = '" & ThnMula & "' Order by Rekod_Kursus.ThnMula"
EndIf
Session("mySelectQuery") = mySelectQuery
EndSub
|
then recall it in datagrid by :
Quote:
<Columns>
<asp:HyperLinkColumnDataNavigateUrlField="ID"DataNavigateUrlFormatString="http:/SMPB/kursusMaintainB.aspx?UserID={0}" DataTextField="NoRujukan"HeaderText="No Rujukan"><HeaderStyleWidth="130px"></HeaderStyle></asp:HyperLinkColumn>
<asp:BoundColumnDataField="FullName"HeaderText="Nama Pegawai"></asp:BoundColumn>
<asp:BoundColumnDataField="JumlahJam"HeaderText="Jumlah Jam"></asp:BoundColumn>
</Columns>
|
where which i bold is the column name in the database derived from *.
i want to do some calculation to replace ''JumlahJam" with one function.
how can i do it? if i replace JumlahJam with another name that is not from the database. it will yield error message
A field or property with the name 'myFunction' was not found on the selected datasource.
how do i replace it with function?... thanks in advance
-Nazirul
|