Hi,
i am trying to validate that the user has entered "http://" in a textbox boundfield control before saving to the database.
this is what i have:
TextBox txt = (TextBox)FormView1.FindControl("additionalInformationTextBox");
if (txt.Text.IndexOf("http://") == -1)
{
txt.Text = txt.Text.Insert(0, "http://");
}
now i want this new version to be saved in the database. I tried the
FormView1_ItemInserting and AccessDataSourceAddNewWord_Inserting events but they are not adding the updated version of the link into the database.
thanks for the help
john
This works for Updating and inserting event handler..
protectedvoid ObjectDataSource1_Updating(object sender,ObjectDataSourceMethodEventArgs e)
{
//change things before the pipe returns the object to the update method.
//grab my object
DbTableEntity d = (DbTableEntity)e.InputParameters[0];
if (!((TextBox)GridView1.Rows[GridView1.EditIndex].FindControl("tbRetDate")).Text.Length.Equals(0))
{
d.RetireDate =DateTime.Parse(((TextBox)GridView1.Rows[GridView1.EditIndex].FindControl("tbRetDate")).Text);
}
}
No comments:
Post a Comment