Parameter.Parameter(String, TypeCode, String) Constructor
.NET Framework 3.0
Initializes a new instance of the Parameter class, using the specified name, the specified type, and the specified string for its DefaultValue property.
Namespace: System.Web.UI.WebControls
Assembly: System.Web (in system.web.dll)
Assembly: System.Web (in system.web.dll)
public Parameter ( String name, TypeCode type, String defaultValue )
public function Parameter ( name : String, type : TypeCode, defaultValue : String )
Not applicable.
Parameters
- name
The name of the parameter.
- type
A TypeCode that describes the type of the parameter.
The following code example demonstrates how to use the Parameter(String,TypeCode,String) constructor to add update parameter objects to the UpdateParameters collection of an AccessDataSource control before calling the Update method.
<script runat="server">
private void UpdateRecords(Object source, System.EventArgs e)
{
// This method is an example of batch updating using a
// data source control. The method iterates through the rows
// of the GridView, extracts each CheckBox from the row and, if
// the CheckBox is checked, updates data by calling the Update
// method of the data source control, adding required parameters
// to the UpdateParameters collection.
CheckBox cb;
for (int iCtr = 0;
iCtr < this.GridView1.get_Rows().get_Count(); iCtr++) {
GridViewRow row = this.GridView1.get_Rows().get_Item(iCtr);
cb = (CheckBox)row.get_Cells().get_Item(0).get_Controls().get_Item(1);
if (cb.get_Checked()) {
String oid = (String)(row.get_Cells().get_Item(1).get_Text());
MyAccessDataSource.get_UpdateParameters().Add(new Parameter(
"date", System.TypeCode.DateTime, System.DateTime.get_Now().ToString()));
MyAccessDataSource.get_UpdateParameters().Add(new Parameter(
"orderid", System.TypeCode.String, oid));
MyAccessDataSource.Update();
MyAccessDataSource.get_UpdateParameters().Clear();
}
}
} //UpdateRecords
</script>
Community Additions
ADD
Show: