2
Answers

How to validate data table(datas) in data set?

Raja

Raja

8y
209
1
i have one dataset and multiple(like 4 or 5 tables) datatable(with different rows and columns count). In this data table i have some mandatory field to validate.<br /> 1.item number (itemnumber:12)(itemnumber is description it is in any row and the value of item number(12) is next same row and next column of the description)<br /> 2.manufacturer name<br /> 3.rev number.<br /><div> now i want to validate the in this manner how to do it.</div><div>&nbsp;</div><div><strong>What I have tried:</strong><br /> <br /> I used <br /> if (ds.Tables[i].Rows[12][25].ToString() == "")<br /> {<br /> dt.Rows.Add();<br /> dt.Rows[mn][0] = "Item number Should be mandatory";<br /> <br /> }<br /> in this code particular field is empty to add the message to one table and show.but the column and row values are changed. </div>
Answers (2)
0
Bikesh Srivastava

Bikesh Srivastava

NA 19.8k 835k 8y
Hi,
try this code if resolve mark as answer otherwise reply me.
  1. publicboolHashDataset(DataSetds)
  2. {
  3. if(!ds.Tables.Contains("NameDataset"))
  4. returnfalse;
  5. intindex=ds.Tables["NameDataset"].Rows.Count;
  6. if(index<1)
  7. returnfalse;
  8. returntrue;
  9. }
Accepted
0
Vinay Singh

Vinay Singh

NA 5.9k 126.1k 8y
check the link this will help you
https://msdn.microsoft.com/en-us/library/kx9x2fsb.aspx
http://www.c-sharpcorner.com/blogs/how-to-validate-dataset-with-data-in-c-sharp1
http://stackoverflow.com/questions/2976473/how-to-test-if-a-dataset-is-empty