I have a
protected void gvTimeSheet_DataBound(object sender, EventArgs e)
DataTable dt = new DataTable();
int intUserID = TypeConvert.IsNullInt32(ddlUsers.SelectedValue, 0);
DateTime fromDate = Convert.ToDateTime(UCFromDate.selectedDate);
DateTime toDate = Convert.ToDateTime(UCToDate.selectedDate);
string strQuery = "EXEC SPRptUserTimeSheet_AP @User=" + intUserID + ",@dateFrom='" + fromDate + "',@dateTo='" + toDate + "'";
dt = DataHelper.ExecuteQuery(strQuery);
foreach (DataRow row in dt.Rows)
string userName = row.ToString();
string bookedHr = row.ToString();
string timezone = row.ToString();
if (userName == string.Empty)
row = ddlUsers.SelectedItem.Text;
if (bookedHr == string.Empty)
row["Booked Hrs"] = 0.0;
if (bookedHr != string.Empty)
row["Booked Hrs"] = objCommon.fnGetEffortInHrMinFormat(Convert.ToInt32(bookedHr));
if (timezone == "0")
row["Time Zone"] = "Offshore";
if (timezone == "1")
row["Time Zone"] = "Onsite";
ViewState["dtExport"] = dt;
What you are trying to do does not really make sense:
To understand why, you need to consider what the expression
row really means. It means
the value of column 6 in this row.
So the only way to realistically remove the column 6 from the row would be to delete it from the table:
That would get rid of the column alright. But then you have removed it for ALL rows.
So you cannot do this from within the
foreach loop. If you did you would remove
Until you have an exception that you are trying to remove a column outside the bounds of the Column collection.
So, if you must indeed get rid of column 6 do so after the loop.