本文整理汇总了C#中System.Web.UI.WebControls.FormView类的典型用法代码示例。如果您正苦于以下问题:C# FormView类的具体用法?C# FormView怎么用?C# FormView使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FormView类属于System.Web.UI.WebControls命名空间,在下文中一共展示了FormView类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetDdlValue
public int GetDdlValue(FormView fv, string name)
{
var ddl = fv.FindControl(name) as DropDownList;
if (ddl.SelectedValue != null)
return Convert.ToInt32(ddl.SelectedValue);
return -1;
}
示例2: LoadUITestDataFromFormView
public static void LoadUITestDataFromFormView(FormView formViewEmployee)
{
TextBox txtFirstName = (TextBox)formViewEmployee.FindControl("txtFirstName");
TextBox txtLastName = (TextBox)formViewEmployee.FindControl("txtLastName");
TextBox txtHireDate = (TextBox)formViewEmployee.FindControl("txtHireDate");
TextBox txtAddress = (TextBox)formViewEmployee.FindControl("txtAddress");
TextBox txtHomePhone = (TextBox)formViewEmployee.FindControl("txtHomePhone");
DropDownList ddlCountry = (DropDownList)formViewEmployee.FindControl("ddlCountry");
//since in read-only mode there is no text box control
if (formViewEmployee.CurrentMode != FormViewMode.ReadOnly)
{
////using data value in form in custom way
//populating per-fill data
if (formViewEmployee.CurrentMode == FormViewMode.Insert)
{
txtFirstName.Text = "Ashraful";
txtLastName.Text = "Alam";
txtHireDate.Text = DateTime.Now.ToString();
txtAddress.Text = "One Microsoft Way";
txtHomePhone.Text = "912200022";
ddlCountry.Items.FindByText("USA").Selected = true;
}
}
}
示例3: BindControl
/// <summary>
/// Binds a controls value to a property of an entity.
/// </summary>
/// <param name="formView">A <see cref="FormView"/> object.</param>
/// <param name="list">The <see cref="IOrderedDictionary"/> containing the values.</param>
/// <param name="propertyName">The name of the property to bind the value to.</param>
/// <param name="controlId">The id of the control to get the value from.</param>
public static void BindControl(FormView formView, IOrderedDictionary list, string propertyName, string controlId)
{
if (formView != null)
{
Control control = formView.FindControl(controlId);
BindControl(control, list, propertyName);
}
}
示例4: extractTextBoxValue
protected string extractTextBoxValue(FormView fv,string controlID)
{
try
{
return (fv.FindControl(controlID) as TextBox).Text;
}
catch (NullReferenceException ex)
{
return null;
}
}
示例5: BindFormView
public FormView BindFormView(FormView grdVGenIn, string strSqlIn)
{
objConnection = open_connection();
if (open_con == true)
{
try
{
objDataSet = new DataSet();
objAdapter = new OracleDataAdapter(strSqlIn, objConnection);
objAdapter.Fill(objDataSet, "tblGrdV");
grdVGenIn.DataSource = objDataSet.Tables["tblGrdV"].DefaultView;
grdVGenIn.DataBind();
gridView_bind = true;
return grdVGenIn;
}
catch (OracleException objError)
{
if (objError.Message.Substring(0, 21) == "Table does not exist.")
{
ErrorStr = ErrorMsg(objConnection, "MSG1201");
}
else if (objError.Message.Substring(59, 25) == "ORA-00904: invalid column name")
{
ErrorStr = ErrorMsg(objConnection, "MSG1202");
}
else
{
ErrorStr = objError.Message;
err_flag = true;
}
gridView_bind = false;
return null;
}
finally
{
objConnection.Close();
objConnection.Dispose();
objAdapter.Dispose();
}
}
else
{
return null;
}
}
示例6: Build
public void Build(FormView form, IConfigurationSection section, IBinder binder, IDictionary<string, object> boundControls, IDictionary<string, object> dataSources)
{
if (null == form)
{
throw new ArgumentNullException("form");
}
if (null == section)
{
throw new ArgumentNullException("section");
}
if (null == binder)
{
throw new ArgumentNullException("binder");
}
this._boundControls = boundControls;
this._boundControls.Clear();
this._dataSources = dataSources;
this._dataSources.Clear();
form.EditItemTemplate = new TemplateHelper(this.BuildItemTemplate(section, binder, FormViewMode.Edit), section);
}
示例7: RedirectAfterDelete
/// <summary>
/// Redirects the client to a new URL after the ItemDeleted event of
/// the <see cref="FormView"/> object has been raised.
/// </summary>
/// <param name="formView">A <see cref="FormView"/> object.</param>
/// <param name="url">The target location.</param>
public static void RedirectAfterDelete(FormView formView, String url)
{
RedirectAfterDelete(formView, url, null);
}
示例8: SetOnUpdating
/// <summary>
/// Sets the values to update using the specified names and values.
/// </summary>
/// <param name="formView">A <see cref="FormView"/> object.</param>
/// <param name="names">The property names.</param>
/// <param name="values">The property values.</param>
public static void SetOnUpdating(FormView formView, String[] names, Object[] values)
{
formView.ItemUpdating += new FormViewUpdateEventHandler(
delegate(object sender, FormViewUpdateEventArgs e)
{
SetValues(e.NewValues, names, values);
}
);
}
示例9: SetDefaultMode
/// <summary>
/// Sets the data-entry mode of the specified <see cref="FormView"/> object based
/// on whether or not the <see cref="HttpRequest"/> parameter value is null.
/// </summary>
/// <param name="formView">A <see cref="FormView"/> object.</param>
/// <param name="requestParameterName">The <see cref="HttpRequest"/> parameter name.</param>
public static void SetDefaultMode(FormView formView, String requestParameterName)
{
if ( String.IsNullOrEmpty(HttpContext.Current.Request[requestParameterName]) )
{
formView.DefaultMode = FormViewMode.Insert;
HideButton(formView, "UpdateButton");
}
else
{
formView.DefaultMode = FormViewMode.Edit;
HideButton(formView, "InsertButton");
}
}
示例10: InitPassword
/// <summary>
/// Initializes a password <see cref="TextBox"/> control with the current value.
/// </summary>
/// <param name="formView">A <see cref="FormView"/> object.</param>
/// <param name="controlId">The control's ID property value.</param>
/// <param name="dataSource">The associated <see cref="ILinkedDataSource"/> object.</param>
/// <param name="propertyName">The property name that the <see cref="TextBox"/> is bound to.</param>
public static void InitPassword(FormView formView, String controlId, ILinkedDataSource dataSource, String propertyName)
{
if ( formView != null && !formView.Page.IsPostBack && dataSource != null &&
!String.IsNullOrEmpty(controlId) && !String.IsNullOrEmpty(propertyName) )
{
TextBox input = formView.FindControl(controlId) as TextBox;
if ( input != null )
{
Object entity = dataSource.GetCurrentEntity();
if ( entity != null )
{
String password = EntityUtil.GetPropertyValue(entity, propertyName) as String;
InitPassword(input, password);
}
}
}
}
示例11: setInternalValueCheckBox
public static void setInternalValueCheckBox(String CheckBoxId, Boolean value, FormView frm)
{
CheckBox t = (CheckBox)frm.FindControl(CheckBoxId);
if (t != null)
{
t.Checked = value;
}
}
示例12: BindOnInserting
/// <summary>
/// Binds a property's value to a <see cref="FormView" /> child control when the <see cref="FormView"/> is inserting.
/// </summary>
/// <param name="formView">A <see cref="FormView"/> object.</param>
/// <param name="propertyName">The name of the property to bind the value to.</param>
/// <param name="controlId">The id of child control that contains the desired value.</param>
public static void BindOnInserting(FormView formView, string propertyName, string controlId)
{
if (formView != null)
{
formView.ItemInserting += new FormViewInsertEventHandler(
delegate(object sender, FormViewInsertEventArgs e)
{
BindControl(formView, e.Values, propertyName, controlId);
}
);
}
}
示例13: ClearFormView
public FormView ClearFormView(FormView grdVGenIn)
{
grdVGenIn.DataSource = null;
grdVGenIn.DataBind();
return null;
}
示例14: RedirectAfterUpdateCancel
/// <summary>
/// Redirect the client to a new URL after an update or cancel operation.
/// </summary>
/// <param name="formView">A <see cref="FormView"/> object.</param>
/// <param name="url">The target location.</param>
public static void RedirectAfterUpdateCancel(FormView formView, String url)
{
RedirectAfterUpdateCancel(formView, url, null);
}
示例15: RedirectAfterCancel
/// <summary>
/// Redirects the client to a new URL after the ItemCommand event of
/// the <see cref="FormView"/> object has been raised with a CommandName
/// of "Cancel".
/// </summary>
/// <param name="formView">A <see cref="FormView"/> object.</param>
/// <param name="url">The target location.</param>
/// <param name="dataSource">The associated <see cref="ILinkedDataSource"/> object.</param>
public static void RedirectAfterCancel(FormView formView, String url, ILinkedDataSource dataSource)
{
formView.ItemCommand += new FormViewCommandEventHandler(
delegate(object sender, FormViewCommandEventArgs e)
{
// cancel button
if ( String.Compare("Cancel", e.CommandName, true) == 0 )
{
Redirect(url, dataSource);
}
}
);
}