如何获取数据列表中最后一行的值? [英] how to get the values of last row in a datalist?
本文介绍了如何获取数据列表中最后一行的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何从数据列表中的数据集中获取最后一行的值...
how to get the last row values from data set in datalist...
推荐答案
数据集中的最后一行值
// Assuming 1st table
myDataset.Tables[0].Rows[myDataset.Tables[0].Rows.Count - 1]["ColumnNameForWhichValueNeeded"]
如何从数据集中获取最后一行的值
我认为它是数据表,因为数据集不直接包含任何行.
这给出了数据表的最后一行.
how to get the last row values from data set
I think it is datatable as dataset doesn''t contain any rows directly.
This gives the last row of the datatable.
datatable.Rows[datatable.Rows.Count - 1]
DataSet.Tables[0].Rows[DataSet.Tables[0].Rows.Count -1]
//this way yo can get the Count Of rows
int LastRowNumber = Convert.ToInt32(ds.Tables[0].Rows.Count);
//if your Want the last row index (Suppose your LastRowNumber =6)
because indexStart From 0
int Id = Convert.ToInt32(ds.Tables[0].Rows[5]["MyId"]);
//Another Way (Your Will get the Last Index Directly)
int LastRowNumber = Convert.ToInt32(ds.Tables[0].Rows.Count-1);
<pre>
这篇关于如何获取数据列表中最后一行的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文