本文整理匯總了C#中MonoTests.System.Web.UI.WebControls.ObjectDataSourcePoker.Delete方法的典型用法代碼示例。如果您正苦於以下問題:C# ObjectDataSourcePoker.Delete方法的具體用法?C# ObjectDataSourcePoker.Delete怎麽用?C# ObjectDataSourcePoker.Delete使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類MonoTests.System.Web.UI.WebControls.ObjectDataSourcePoker
的用法示例。
在下文中一共展示了ObjectDataSourcePoker.Delete方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: DeleteMethod
public static void DeleteMethod (Page p)
{
LiteralControl lcb = new LiteralControl (HtmlDiff.BEGIN_TAG);
LiteralControl lce = new LiteralControl (HtmlDiff.END_TAG);
MyTableObject.ds = MyTableObject.CreateDataTable ();
DetailsView dv = new DetailsView ();
ObjectDataSourcePoker ods = new ObjectDataSourcePoker ();
ods.Deleted += new ObjectDataSourceStatusEventHandler (odc_Deleted);
ods.Deleting += new ObjectDataSourceMethodEventHandler (odc_Deleting);
InitObjectDataSource (ods,"");
dv.Page = p;
ods.Page = p;
dv.DataKeyNames = new string[] { "ID" };
dv.DataSource = ods;
p.Controls.Add (lcb);
p.Controls.Add (ods);
p.Controls.Add (dv);
p.Controls.Add (lce);
dv.DataBind ();
Assert.AreEqual (3, dv.DataItemCount, "BeforeDelete1");
Assert.AreEqual (1001, dv.SelectedValue, "BeforeDelete2");
Assert.AreEqual (false, deleting, "BeforeDeletingEvent");
Assert.AreEqual (false, deleted, "BeforeDeletedEvent");
ods.Delete ();
dv.DataBind ();
Assert.AreEqual (true, deleting, "AfterDeletingEvent");
Assert.AreEqual (true, deleted, "AfterDeletedEvent");
Assert.AreEqual (2, dv.DataItemCount, "BeforeDelete1");
Assert.AreEqual (1002, dv.SelectedValue, "BeforeDelete2");
}
示例2: ConvertNullToDBNull
public static void ConvertNullToDBNull (Page p)
{
ObjectDataSourcePoker ods = new ObjectDataSourcePoker ();
InitObjectDataSource (ods,"DBNull");
bool dbnull = false;
ods.ConvertNullToDBNull = true;
try {
ods.Delete ();
}
catch (Exception ex) {
Assert.AreEqual (true,
ex.Message.Contains ("type 'System.DBNull' cannot be converted to type 'System.String'") || // dotnet
ex.Message.Contains ("type System.DBNull cannot be converted to target type: System.String")); // mono
dbnull = true;
}
Assert.AreEqual (true, dbnull, "ConvertNullToDBNull2");
}