×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

int type causes error

int type causes error

int type causes error

(OP)
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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close