daniel50096230
Member
- Joined
- Jan 5, 2009
- Messages
- 8
- Programming Experience
- Beginner
Basically,I would like to bind the data into gridview which called PODetailsGrid during page_load. After the data had been bind into the gridview,I would like to make alternate color in each row. For example, the font color for row1 is Black,then second row should be Red,then third row will be Black again...Anyone can teach me how to make that??
VB.NET:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
GeneratePODetailsView(GenerateDataSource())
End Sub
Private Sub GeneratePODetailsView(ByRef ds As DataSet)
PODetailsGrid.DataSource = ds
PODetailsGrid.DataBind()
End Sub
Private Function GenerateDataSource(Optional ByVal blnShowAll As Boolean = False) As DataSet
Dim ds As DataSet
ds = RetrievePODetails(Session.Item("UserID"), Session.Item("POID"))
Return ds
End Function
Private Function RetrievePODetails(ByVal callerUserID As String, ByVal POID As String) As DataSet
Dim objDB As New clsDB
Try
Dim sql As String = [String].Empty
If Session.Item("POStatus") = "Partially Accepted" Or Session.Item("POStatus") = "Partially Rejected" Or Session.Item("POStatus") = "Ammended Read" Or Session.Item("POStatus") = "Ammended Unread" Or Session.Item("POStatus") = "Cancelled" Then
sql = "SELECT [POID], [LineNo], [SellerItemNo], [BuyerStyleNo], "
sql &= "[GTIN], [ItemDesc], [PackSize], [SubPackSize], [Unit], [OrdQty], convert(integer,[InvoiceQty]) As [InvoiceQty], convert(integer,[OrdQty]) -convert(integer,[InvoiceQty]) -convert(integer,[TotQty]) As SelectedQty, [UnitPrice], "
sql &= " convert(integer,[TotQty]) As [TotQty], [RejectedQty] = 0, "
sql &= "[CaseCost], [DiscountAmt], [NetAmt], [QtyFree], [TaxRate], [Size], [RejectedReason], [TaxType] "
'sql &= "CASE WHEN Size ='0' THEN '1' ELSE '0' END AS chkbox, "
'sql &= "CASE WHEN Size ='1' THEN '1' ELSE '0' END AS chked, "
'sql &= "CASE WHEN Size ='0' THEN 1 ELSE 0 END AS Visible"
sql &= " FROM Trn_PO_Details WITH (NOLOCK) WHERE POID='" + POID + "' ORDER BY [LineNo];"
ElseIf Session.Item("POStatus") = "Accept All" Or Session.Item("POStatus") = "Reject All" Or Session.Item("POStatus") = "Completed" Then
sql = "SELECT [POID], [LineNo], [SellerItemNo], [BuyerStyleNo], "
sql &= "[GTIN], [ItemDesc], [PackSize], [SubPackSize], [Unit], [OrdQty], convert(integer,[InvoiceQty]) As [InvoiceQty], [SelectedQty] = 0, [UnitPrice], "
sql &= " convert(integer,[TotQty]) As [TotQty], [RejectedQty] = 0,"
sql &= "[CaseCost], [DiscountAmt], [NetAmt], [QtyFree], [TaxRate], [Size], [RejectedReason], [TaxType] "
'sql &= "CASE WHEN Size ='0' THEN '1' ELSE '0' END AS chkbox, "
'sql &= "CASE WHEN Size ='1' THEN '1' ELSE '0' END AS chked, "
'sql &= "CASE WHEN Size ='0' THEN 1 ELSE 0 END AS Visible"
sql &= " FROM Trn_PO_Details WITH (NOLOCK) WHERE POID='" + POID + "' ORDER BY [LineNo];"
Else
sql = "SELECT [POID], [LineNo], [SellerItemNo], [BuyerStyleNo], "
sql &= "[GTIN], [ItemDesc], [PackSize], [SubPackSize], [Unit], [OrdQty], convert(integer,[InvoiceQty]) As [InvoiceQty], convert(integer,[OrdQty]) As [SelectedQty], [UnitPrice], "
sql &= " convert(integer,[TotQty]) As [TotQty], [RejectedQty] = 0,"
sql &= "[CaseCost], [DiscountAmt], [NetAmt], [QtyFree], [TaxRate], [Size], [RejectedReason], [TaxType] "
'sql &= "CASE WHEN Size ='0' THEN '1' ELSE '0' END AS chkbox, "
'sql &= "CASE WHEN Size ='1' THEN '1' ELSE '0' END AS chked, "
'sql &= "CASE WHEN Size ='0' THEN 1 ELSE 0 END AS Visible"
sql &= " FROM Trn_PO_Details WITH (NOLOCK) WHERE POID='" + POID + "' ORDER BY [LineNo];"
'sql &= "[GTIN], [ItemDesc], [PackSize], [SubPackSize], [Unit], [OrdQty], convert(integer,[InvoiceQty]) As [InvoiceQty], SelectedQty = 0, [UnitPrice], "
End If
objDB.OpenDataSet(dsRepeater, sql)
dsRepeater.Tables(0).TableName = "PurchaseOrderDetails"
dsRepeater.DataSetName = "PODetailsSet"
Return dsRepeater
Catch e As Exception
btnPrint.Enabled = False
btnInvoice.Enabled = False
btnCsv.Enabled = False
btnPdf.Enabled = False
'btnAccept.Enabled = False
'btnReject.Enabled = False
btnSubmit.Enabled = False
systemlog.Add(callerUserID, "ApplicationException", "Fail to retrieve Mydin Purchase Order Details records.", e.Message + e.StackTrace)
MessageBox("Fail to retrieve Purchase Order Details Trailers records.")
Throw New Exception()
Finally
objDB = Nothing
End Try
End Function