做了这么长时间ASP.NET,头一回遇到这么一个令人郁闷的问题,大家给个办法吧。
data是类NewsData的一个实例,NewsData继承于DataSet.
下面是命令窗口-立即的调试情况:
data.Tables["News"] //输入
//以下是输出结果
{System.Data.DataTable}
System.ComponentModel.MarshalByValueComponent: {System.Data.DataTable}
_colUnique: <未定义的值>
_nestedParentRelation: <未定义的值>
caseSensitive: false
CaseSensitive: false
caseSensitiveAmbient: true
ChildRelations: {System.Data.DataRelationCollection.DataTableRelationCollection}
childRelationsCollection: {System.Data.DataRelationCollection.DataTableRelationCollection}
columnCollection: {System.Data.DataColumnCollection}
Columns: {System.Data.DataColumnCollection}
compareFlags: 25
compareInfo: {System.Globalization.CompareInfo}
constraintCollection: {System.Data.ConstraintCollection}
Constraints: {System.Data.ConstraintCollection}
culture: <未定义的值>
DataSet: {Common.Data.NewsData}
dataSet: {Common.Data.NewsData}
DefaultView: {System.Data.DataView}
defaultView: {System.Data.DataView}
delayedSetPrimaryKey: <未定义的值>
delayedViews: {Count=0}
displayExpression: <未定义的值>
DisplayExpression: ""
dvListeners: {Count=1}
ElementColumnCount: 13
elementColumnCount: 13
encodedTableName: "News"
EncodedTableName: "News"
enforceConstraints: true
EnforceConstraints: true
extendedProperties: {System.Data.PropertyCollection}
ExtendedProperties: {System.Data.PropertyCollection}
fComputedColumns: true
fInitInProgress: false
fNestedInDataset: true
HasErrors: false
inDataLoad: false
indexes: {Count=1}
indexesLock: {System.Threading.ReaderWriterLock}
initialLoad: false
KEY_NAME: "TableName"
KEY_XMLDIFFGRAM: "XmlDiffGram"
KEY_XMLSCHEMA: "XmlSchema"
LiveIndexes: {Count=1}
loadIndex: <未定义的值>
Locale: {System.Globalization.CultureInfo}
MaxOccurs: 1
maxOccurs: 1
mergingData: false
MergingData: false
MinimumCapacity: 50
MinOccurs: 1
minOccurs: 1
Namespace: ""
nestedParentRelation: <未定义的值>
nextRowID: 1
onColumnChangedDelegate: <未定义的值>
onColumnChangingDelegate: <未定义的值>
onPropertyChangingDelegate: <未定义的值>
onRowChangedDelegate: <未定义的值>
onRowChangingDelegate: <未定义的值>
onRowDeletedDelegate: <未定义的值>
onRowDeletingDelegate: <未定义的值>
ParentRelations: {System.Data.DataRelationCollection.DataTableRelationCollection}
parentRelationsCollection: {System.Data.DataRelationCollection.DataTableRelationCollection}
Prefix: ""
primaryIndex: {Length=0}
primaryKey: <未定义的值>
PrimaryKey: {Length=0}
propertyDescriptorCollectionCache: {System.ComponentModel.PropertyDescriptorCollection}
RecordCapacity: 0
recordManager: {System.Data.RecordManager}
repeatableElement: false
rowBuilder: {System.Data.DataRowBuilder}
rowCollection: {System.Data.DataRowCollection}
Rows: {System.Data.DataRowCollection}
savedEnforceConstraints: false
saveIndexes: <未定义的值>
SchemaLoading: false
schemaLoading: false
shadowIndexes: <未定义的值>
Site: <未定义的值>
TableName: "News"
tableName: "News"
tableNamespace: null
tablePrefix: ""
textOnly: false
typeName: {System.Xml.XmlQualifiedName}
xmlText: <未定义的值>
XmlText: <未定义的值>
zeroColumns: {Length=0}
zeroIntegers: {Length=0}
NewsData.T_News_Table //输入
"News"//输出
data.Tables[NewsData.T_News_Table]//输入
错误: 对象“data.Tables”没有索引器//输出,看,郁闷的地方到了。这是为什么?