Hi
I have below Gridview. In below line it shows value . Last column is Date. It should be either space or Date
gr.Cells[gr.Cells.Count - 1]
SQLUtility sQLUtility = new SQLUtility();
DataTable dt = sQLUtility.GeBookPlanningRecommendation(HRpl, BookCollection, StudentCollection).Tables[0];
if (dt != null)
{
DataColumn Remarks = new DataColumn("Remarks", typeof(string));
dt.Columns.Add(Remarks);
DataColumn Dates = new DataColumn("Date", typeof(DateTime));
dt.Columns.Add(Dates);
}
}
*******************************
foreach (GridViewRow gr in grdPlanning.Rows)
{
//string sessionDate = "";
if (gr.RowType == DataControlRowType.DataRow)
{
if (gr.Cells[gr.Cells.Count - 1].Text != "")
{
}
}
}
Thanks
Ramco RamcoPosted May 5, 2023, 6:38 AM
Hi RajKiran
I have below code in GridView RowDataBound
Thanks
Ramco RamcoPosted May 5, 2023, 5:39 AM
Hi Rajkiran
Issue is it show value in dateString. I don't want to consider these rows. I have changed Date as string type also but still it is not working.
string dateString = gr.Cells[gr.Cells.Count - 1].Text.Trim();
if (!string.IsNullOrEmpty(dateString))
Rajkiran SwainPosted May 5, 2023, 5:31 AM
Ramco RamcoPosted May 5, 2023, 4:54 AM
Hi Rajkiran
In Gridview RowDataBound i have written this but still it is showing
row[e.Row.Cells.Count - 1] = "";
User will enter datein dd-mm-yyyy so what i should change. If it is valid Date then it should go further. Value in below should be valid Date
gr.Cells[gr.Cells.Count - 1].Text
Even if type of Date is declared as string thean also it shows . It should show empty if nothinh is entered in the column.
Thanks
Rajkiran SwainPosted May 5, 2023, 4:49 AM
The
is an HTML non-breaking space code that is used to create a space between two words that cannot be separated by a line break. It seems like the value in the last column of yourGridViewis being displayed asinstead of a space or a valid date.To fix this, you can check the data that is being passed into the
GridViewand ensure that the last column contains a validDateTimevalue. You can also try removing any formatting or encoding that may be causing theto appear.As for the code snippet you provided, it seems like you are adding two columns "Remarks" and "Date" to a
DataTableobject and then looping through the rows of aGridViewto check if the value in the last cell is not empty. However, without seeing the entire code and the data being passed, it's difficult to determine the root cause of the issue.gr.Cells[gr.Cells.Count - 1].Text = myDate.ToString("MM/dd/yyyy");