| | |
what's the error...??
Please support our VB.NET advertiser: Intel Parallel Studio Home
![]() |
can somebody tell m,
what's the error in below code-where all the columns with sex="male" should be displayed with color choclate in datagrid...plz
--------------------------------------
ProtectedSub datagrid1_itemdatabound(ByVal sender AsObject, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles datagrid1.ItemDataBound
If (e.Item.ItemType = ListItemType.Item) Or (e.Item.ItemType = ListItemType.AlternatingItem) Then
Dim str As String
If (e.Item.Cells(3).Text.Equals("male")) Then
'If e.Item.DataItem(2) = Convert.ToString("male") Then
e.Item.Cells(0).BackColor = Color.Chocolate
End If
what's the error in below code-where all the columns with sex="male" should be displayed with color choclate in datagrid...plz
--------------------------------------
ProtectedSub datagrid1_itemdatabound(ByVal sender AsObject, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles datagrid1.ItemDataBound
If (e.Item.ItemType = ListItemType.Item) Or (e.Item.ItemType = ListItemType.AlternatingItem) Then
Dim str As String
If (e.Item.Cells(3).Text.Equals("male")) Then
'If e.Item.DataItem(2) = Convert.ToString("male") Then
e.Item.Cells(0).BackColor = Color.Chocolate
End If
Hello preetham.saroja
i hope ds would help.
i did not use DataGrid instead i used DataGridView.
This is the code...
Private Sub btnFillGrid_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFillGrid.Click
Dim gRow As Integer
'Clear Content of DataGridView
DataGridView1.Rows.Clear()
For gRow = 0 To 9
'Add 10 Records
DataGridView1.Rows.Add()
DataGridView1.Item("dgName", gRow).Value = gRow & " : " & "Sample Data"
DataGridView1.Item("dgAge", gRow).Value = (gRow + 4) * 2
If (gRow Mod 2) Then
DataGridView1.Item("dgSex", gRow).Value = "Male"
Else
DataGridView1.Item("dgSex", gRow).Value = "Female"
End If
Next
End Sub
Private Sub DataGridView1_CellFormatting(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellFormattingEventArgs) Handles DataGridView1.CellFormatting
If DataGridView1.Columns(e.ColumnIndex).Name = "dgSex" Then
If Trim(UCase(DataGridView1.Item("dgSex", e.RowIndex).Value)) = "MALE" Then
e.CellStyle.BackColor = Color.Chocolate
End If
End If
End Sub
Note: I have put DataGridView1 and Commandbutton (btnFillGrid) on my form...
i hope ds would help.
i did not use DataGrid instead i used DataGridView.
This is the code...
Private Sub btnFillGrid_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFillGrid.Click
Dim gRow As Integer
'Clear Content of DataGridView
DataGridView1.Rows.Clear()
For gRow = 0 To 9
'Add 10 Records
DataGridView1.Rows.Add()
DataGridView1.Item("dgName", gRow).Value = gRow & " : " & "Sample Data"
DataGridView1.Item("dgAge", gRow).Value = (gRow + 4) * 2
If (gRow Mod 2) Then
DataGridView1.Item("dgSex", gRow).Value = "Male"
Else
DataGridView1.Item("dgSex", gRow).Value = "Female"
End If
Next
End Sub
Private Sub DataGridView1_CellFormatting(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellFormattingEventArgs) Handles DataGridView1.CellFormatting
If DataGridView1.Columns(e.ColumnIndex).Name = "dgSex" Then
If Trim(UCase(DataGridView1.Item("dgSex", e.RowIndex).Value)) = "MALE" Then
e.CellStyle.BackColor = Color.Chocolate
End If
End If
End Sub
Note: I have put DataGridView1 and Commandbutton (btnFillGrid) on my form...
![]() |
Similar Threads
- Code 19 Registry Error (Windows NT / 2000 / XP)
- Error Loading operating System (Windows NT / 2000 / XP)
- svchost.exe error (Windows NT / 2000 / XP)
- New Hardware Causing Error (Windows NT / 2000 / XP)
- office 2000 install error (Windows NT / 2000 / XP)
- VMWare Unrecoverable Error (*nix Software)
- Error in Wrox Book (Perl)
Other Threads in the VB.NET Forum
- Previous Thread: errors in vb.net
- Next Thread: query insertion in vb.net
| Thread Tools | Search this Thread |
.net .net2008 30minutes 2005 2008 access account arithmetic array basic bing button buttons center check code combobox component connectionstring crystalreport data database databasesearch datagrid datagridview date design dissertation dissertations dropdownlist excel fade file-dialog filter folder ftp generatetags google gridview hardcopy images input insert intel internet mobile monitor ms net networking objects output panel passingparameters peertopeervideostreaming picturebox picturebox1 port position print printing problem problemwithinstallation project save searchbox searchvb.net select serial shutdown soap survey table tcp temperature text textbox timer timespan toolbox trim update updown user vb vb.net vb.netcode vb.netformclosing()eventpictureboxmessagebox vb2008 vbnet view visual visualbasic visualbasic.net visualstudio visualstudio2008 web winforms wpf year





