Hi,
When the data from the I have to display the error message in a different color and also the particular bound column of the griview needs to be highlighted in a different color.
Please find the code below:
email = row("Secondary Viewing Party Email Address").ToString()
If (String.IsNullOrWhiteSpace(email)) Then
_hasErrors = True
Me.ViewState("hasErrors") = True
Return "Error - No Secondary Viewing Party Email Entered" need to show this error messgae in red color
End If
Thanks
Rose
Didn't get the first part of your question, where are you showing that error message. Is it a label or column in the grid
To change the back ground color/text of a cell you can do something like this in RowDataBound
If(e.Row.RowType = DataControlRowType.DataRow) Then
e.Row.Cells(YourCellIndex).Text= your text
e.Row.Cells(yourCellIndex).BackColor=your color
EndIF
Thanks Anwar!! please find the code for the first part
ds.Tables(0).Columns.Add(column)
Dim hasData As Boolean = False
For Each row In ds.Tables(0).Rows
' Primary Relationship
If Not (String.IsNullOrWhiteSpace(row(PRIMARY_ENTITY).ToString)) Then
id = GetIDByName(GetIDByNameColumns.ContractingEntity, row(PRIMARY_ENTITY).ToString)
row.Item("entityID1") = id
Else
_hasErrors = True
Me.ViewState("hasErrors") = True
Dim s As String
s = String.Format(" Error - Please enter an entity name for the primary relationship...")
row.Item("entityID1") = s
End If
First I am checking whether the row of the dataset has any value if there is no value then assigning an error message to that coloumn in the dataset and like wise i need check many columns then at the end i need to bind the dataset to the gridview and has
to show the particular column in the gridview with the different color as well as the error message in the different color.
Hope i m clear. If not pls let me know I will explain you more clearly.
Ok it's bit wiered that you are updating your own dataset. Why can't you eliminate that in your query, why do you have to change the dataset. On top of that if you still need to check the value attach it to a column in grid(it can be a hidden column) and
in the RowDatabound event check for the columns value and basing on condition set the error to the cell text just I mentioned above
If(e.Row.RowType = DataControlRowType.DataRow) Then
e.Row.Cells(YourCellIndex).Text= your text
e.Row.Cells(yourCellIndex).BackColor=your color
EndIF
Anwar,
thanks for the reply. Let me explain my requirement fully. I am loading the excel with the some employee data aftre uploading, the data from the excel are loaded into a dataset at that time we are checking whether any cell is not having data then if there
is any empty cell then diplaying error message. but this error message will be diplayed in the boundcolumn of the gridview once the dataset bound to the gridview. - currently this is working fine.
but now i need display the cells of the gridview which has these error messages alone in a different color. how to achieve this?
Am i clear on explaining my requirement?
Thanks
Rose
hi,
roserex1
s = String.Format(" Error - Please enter an entity name for the primary relationship...")
the span is in wrong syntax . ';' must in style such as :
("
Hope this helps
沒有留言:
張貼留言