Hi,
I have this code which causes an error.
// Edit
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 which causes the erro:
dt.Value.ToLower().Substring(0, 4).Equals("date")
It works fine if dt.Value different to int, e.g. "varchar" or "datetime"
Is this a good fix ?
if(dt.Value != "int" && dt.Value.ToLower().Substring(0, 4).Equals("date"))
TIA
I have this code which causes an error.
// Edit
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 which causes the erro:
dt.Value.ToLower().Substring(0, 4).Equals("date")
It works fine if dt.Value different to int, e.g. "varchar" or "datetime"
Is this a good fix ?
if(dt.Value != "int" && dt.Value.ToLower().Substring(0, 4).Equals("date"))
TIA