English 中文(简体)
指标Of()方法
原标题:the IndexOf() method returns -1 all the time
  • 时间:2010-08-26 08:11:08
  •  标签:
  • c#
  • asp.net

i 有两个数据表,结构相同。

第一部分

第二行

想要的是,在第二个数据表的第一数据表上排在后面的行文。

• 第一个数据表 诱惑

• second

i) 采取下列行动:

DataTable temp = new DataTable();
temp = dt.Clone();
DataColumn[] keyColumn = new DataColumn[1];
keyColumn[0] = temp.Columns["photoId"];
temp.PrimaryKey = keyColumn;
temp = (DataTable)(Session["currentImage"]);
DataRow[] drr = new DataRow[1];

index = dt.Rows.IndexOf(temp.Rows[0]);

但是,指数总是以一个数值 = 1

虽然其内容改变了所有时间

页: 1 Rows.IndexOf(dt.Rows ***)

但是,这不是我想要做的事,而是想做的是,在第一个数据浏览之后再接上数据。 第二份数据表 表1

请帮助我。

最佳回答

知道该编码的表格,因此,有相同数据的两行,但在不同的表格中仍然有不同的行文。

为什么你看一看一看一看一看一看同一主要身份,或者在你看来有什么其他意义?

问题回答

IndexOf() using the default comparer of the object to perform a match. The default comparer of most object is reference comparison, which is explaining why you re keep getting -1.

出于同样的原因:

int iA = 0;
int iB = 0;
object oA = 0;
object oB = 0;

iA == iB = true;
oA == oB = false




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签