what's the error...??

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Jun 2007
Posts: 82
Reputation: preetham.saroja is an unknown quantity at this point 
Solved Threads: 1
preetham.saroja's Avatar
preetham.saroja preetham.saroja is offline Offline
Junior Poster in Training

what's the error...??

 
0
  #1
Sep 10th, 2007
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
--------------------------------------
Protected
Sub 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
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 82
Reputation: preetham.saroja is an unknown quantity at this point 
Solved Threads: 1
preetham.saroja's Avatar
preetham.saroja preetham.saroja is offline Offline
Junior Poster in Training

Re: what's the error...??

 
0
  #2
Sep 12th, 2007
come on guyz,
someone plz help m-tell m what i have todo..i have been googling on this for last 3weeks.i have tried alltype of stuffs...guyz help m out,,,,,,
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 7
Reputation: YHUBZ is an unknown quantity at this point 
Solved Threads: 0
YHUBZ's Avatar
YHUBZ YHUBZ is offline Offline
Newbie Poster

Re: what's the error...??

 
0
  #3
Sep 12th, 2007
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...
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the VB.NET Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC