Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#4.0
Hi,
 
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
Comments
Dinesh Ambaliya at 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
good
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).
 

Cheers
  Permalink  
Rate this: bad
good
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());
  Permalink  

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

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Shai Vashdi 1,518
1 Tadit Dash 350
2 Manas Bhardwaj 319
3 OriginalGriff 243
4 Sergey Alexandrovich Kryukov 205
0 Sergey Alexandrovich Kryukov 9,530
1 OriginalGriff 5,716
2 Peter Leow 4,320
3 Maciej Los 3,540
4 Abhinav S 3,373


Advertise | Privacy | Mobile
Web02 | 2.8.140415.2 | Last Updated 9 Oct 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid