Hi,
This code fails when dt.value = int but works fine with other types such as varchar & datetime:
if (e.CommandName == "Edit")
{
// Get the item
RepeaterItem Item = ((RepeaterItem)((Button)e.CommandSource).NamingContainer);
// Get buttons and repeater
Button savebtn = (Button)(Item.FindControl("btnSave"));
Button editbtn = (Button)(Item.FindControl("btnEdit"));
Repeater rFields = (Repeater)(Item.FindControl("repFields"));
// Store markers
((HiddenField)Item.FindControl("prevEnabled")).Value = btnPreviousRec.Enabled ? "1" : "0";
((HiddenField)Item.FindControl("nextEnabled")).Value = btnNextRec.Enabled ? "1" : "0";
// Enable my fields
foreach (RepeaterItem RI in rFields.Items)
// Get data type
HiddenField dt = (HiddenField)(RI.FindControl("hdnDBDataType"));
// Set controls
if (RI.FindControl("chkSetting").Visible) ((CheckBox)RI.FindControl("chkSetting")).Enabled = true;
if (RI.FindControl("ddlSetting").Visible) ((DropDownList)RI.FindControl("ddlSetting")).Enabled = true;
if (RI.FindControl("txtSetting").Visible)
((TextBox)RI.FindControl("txtSetting")).Enabled = true;
// Check my data type
if (dt.Value.ToLower().Substring(0, 4).Equals("date")) ((CalendarExtender)RI.FindControl("extDateTime")).Enabled = true;
}
This is the line that causes error:
if (dt.Value.ToLower().Substring(0, 4).Equals("date"))
Which is the best way to fix it ?
TIA