1
我想問一下,當我在文本框中鍵入值時,如何比較「可兌換數量」和「可用數量」?如何比較列表與gridview中的文本框
例如,在我的gridview中,我在文本框中鍵入「2」,但可用數量只有「1」。所以我希望顯示錯誤顯示數量不夠。 我的驗證只會做在GridView的最後一行
(我爲我凌亂的編碼技術道歉,我無法發佈圖像,由於低信譽,將在評論截圖)
我的按鈕,點擊
Dim row As GridViewRow
Dim strAvailable As String
Dim strRedeem As String
For Each row In GridView1.Rows
' write ur DB process code here
strAvailable = CType(row.Cells(4).FindControl("lblAvailable"),Label).Text
strRedeem = CType(row.Cells(5).FindControl("txtRedeem"), TextBox).Text
If strRedeem > strAvailable Then
lblMessage.Text = "Quantity not enough"
btnPrint.Visible = False
Else
lblMessage.Text = "Enough Quantity"
btnPrint.Visible = True
End If
Next
end sub
什麼代碼給出錯誤「輸入字符串格式不正確」。當您嘗試將某種類型解析爲其他類型時,通常會出現此錯誤。 – Mairaj
http://postimg.org/image/6tsi1dxzn/ 這是錯誤,當我嘗試添加「測試」 – Trya
好吧,你需要像這樣寫lblMessage.Text =「Total number:」+ totalA.ToString() ; – Mairaj