Click here to Skip to main content
13,005,933 members (99,366 online)
Rate this:
Please Sign up or sign in to vote.
See more:

I want to Get Row information for that i wrote code like this but it show the error

DataTable dtBind = (DataTable)ViewState["dtBind"];
DataRow drow = dtBind.Select("Doc_Id=" + Doc_Id.ToString()+"AND DED_Id="+row.ToString());

the error is : cannot implicitly convert type 'System.Data.DataRow[]' to 'System.Data.DataRow'.
Posted 8-Oct-12 21:11pm
Dinesh Ambaliya 9-Oct-12 3:26am
Use index of datarow like drow[0] or if you have to retrieve more than one record iterate through the datarow with for or foreach loop
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Try with:

DataRow[] drows = dtBind.Select(string.Format("Doc_Id={0} AND DED_Id={1}", Doc_Id, row));

The fact is that Select method returns an array of DataRow objects. It means that the result of the select can be more than one.

You can easly that check if drows.Count > 0, ii means that he found something with that filter. Accessing the row is easy as drows[x] where x is a number of array element (which starts from 0).

Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Select method of Datatable returns an array of DataRow.
so you need to use following code.

DataTable dtBind = (DataTable)ViewState["dtBind"];
DataRow[] drow = dtBind.Select("Doc_Id=" + Doc_Id.ToString()+"AND DED_Id="+row.ToString());

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170628.1 | Last Updated 9 Oct 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100