本文整理汇总了C#中System.Web.UI.WebControls.Table.GetData方法的典型用法代码示例。如果您正苦于以下问题:C# Table.GetData方法的具体用法?C# Table.GetData怎么用?C# Table.GetData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.UI.WebControls.Table
的用法示例。
在下文中一共展示了Table.GetData方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DeleteRow
/// <summary>
/// Deletes a row from the database.
/// </summary>
/// <param name="table">The table in which to delete the row.</param>
/// <param name="rowKeys">The row ID.</param>
/// <returns></returns>
internal static bool DeleteRow(Table table, string rowKeys)
{
if (Grid.GotHttpContext &&
System.IO.File.Exists(String.Format("{0}\\noupdate.webgrid", HttpContext.Current.Server.MapPath("."))) &&
table.m_Grid.Tag["allowupdate"] == null)
{
string content =
System.IO.File.ReadAllText(String.Format("{0}\\noupdate.webgrid", HttpContext.Current.Server.MapPath(".")));
table.m_Grid.SystemMessage.Add(
String.IsNullOrEmpty(content)
? "Inserting, updating, or deleting a database record functionality has been disabled."
: content);
return false;
}
table.GetData(false);
if (table.m_Grid.MasterTable.Rows.Count == 0)
return true;
if ( table.DataSource != null || table.m_Grid.MasterTable.Rows[0].DataRow != null)
{
string tmpId = table.m_Grid.InternalId;
table.m_Grid.InternalId = rowKeys;
table.m_Grid.MasterTable.GetData(true);
switch (table.DataSourceType)
{
case DataSourceControlType.SqlDataSource:
case DataSourceControlType.AccessDataSource:
DeleteDataSourceControl(table.m_Grid.MasterTable.Rows[0]);
break;
case DataSourceControlType.ObjectDataSource:
DeleteObjectDataSourceControl(table.m_Grid.MasterTable.Rows[0]);
break;
}
if (table.m_XmlDataDocument == null)
{
table.m_Grid.MasterTable.Rows[0].DataRow.Delete();
if ( table.DataSource != null && table.DataSource is OleDbDataAdapter)
{
try
{
OleDbCommandBuilder updateCommand =
new OleDbCommandBuilder((OleDbDataAdapter) table.DataSource);
((OleDbDataAdapter) table.DataSource).Update(
table.m_Grid.MasterTable.Rows[0].DataRow.Table);
updateCommand.Dispose();
}
catch (Exception ee)
{
throw new GridException("Error deleting record from data source.", ee);
}
}
table.m_Grid.MasterTable.Rows[0].DataRow.Table.AcceptChanges();
}
else if (table.m_XmlDataDocument != null)
{
try
{
List<Column> datacolumns = table.Columns.Primarykeys;
if (datacolumns == null)
{
table.m_Grid.SystemMessage.Add("Primary key is required for the XML file to delete rows.",
true);
return false;
}
foreach (DataTable dt in table.m_XmlDataSet.Tables)
{
if (dt.TableName != rowKeys) continue;
int count = dt.Rows.Count;
for (int i = 0; i < count; i++)
table.m_XmlDataSet.Tables[dt.TableName].Rows.RemoveAt(0);
break;
}
table.m_XmlDataSet.AcceptChanges();
table.m_XmlDataSet.WriteXml(table.m_XmlDataDocument);
}
catch (Exception ee)
{
throw new GridDataSourceException("Error removing row in XML", ee);
}
}
table.m_Grid.InternalId = tmpId;
}
else
{
string datasourcetable = table.DataSourceId;
if( datasourcetable == null)
//.........这里部分代码省略.........