Click here to Skip to main content
15,878,809 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

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

C#
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
Comments
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

Try with:

C#
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
 
Share this answer
 
Select method of Datatable returns an array of DataRow.
so you need to use following code.

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

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900