I have many API data but i take only few data of that..
mean in my API Data i have 10 records and i need only 5 of them.
so,how to take few data of them?
please,explain with example and give code of that..
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Jignesh TrivediRank #16 · 50.3K reputationPosted Jul 7, 2013, 7:44 PM EDT
hi,
you mean to say you required less amount of data which return from API right?
so in this case I think you have to put some extra filter on the data which is return from API or you can change API function that return amount of data that you want...
hope this will help you.
Dipika Shah102 reputationPosted Jul 7, 2013, 9:45 PM EDT
but i have no idea how to take data from API..
can u give me example of this.
Jignesh TrivediRank #16 · 50.3K reputationPosted Jul 7, 2013, 10:02 PM EDT
generally API is in form of dll.
so you have to take reference on API to your project and create instance of API provider class and direct call methods. also from ASP.net MVC 4.0 web api is also available
http://www.asp.net/web-api/overview/getting-started-with-aspnet-web-api/tutorial-your-first-web-api
please refer
http://www.c-sharpcorner.com/UploadFile/mahesh/dll12222005064058AM/dll.aspx
hope this will help you.
Dipika Shah102 reputationPosted Jul 7, 2013, 10:17 PM EDT
Dipika Shah102 reputationPosted Jul 7, 2013, 11:32 PM EDT
plz,give me example.
Jignesh TrivediRank #16 · 50.3K reputationPosted Jul 8, 2013, 12:06 AM EDT
this API is created by you or it is third party?
if it is created by you, than you can write one over load method in API which is return less amount data that you want.
if API is third party than you have write extra code to further filter data.
for example i have one API in form of dll called Abc and i want to call xyz method from API which is return collection of string.
first i will create object of abc (it might be class or assabmly)
Abc test = new Abc();
than i called its method
List
this method returns 15 record and i want to only five record from this collection.
List
this will return only five data from whole data list
hope this will help you.
Dipika Shah102 reputationPosted Jul 8, 2013, 12:37 AM EDT
my API is third party..
can u tell me how to filter the data?
sorry, it's my mistake.i have 10 field and i get 5 of them..
i develop movie multiplex software inthat i have movieId,name,image,screen,showtime,cast,genre,duration,releasedate etc...
and i want to display first 5 of them..
plz, give me rply as fast as soon possible.
thanx in advance.
Jignesh TrivediRank #16 · 50.3K reputationPosted Jul 8, 2013, 1:11 AM EDT
you have 10 field (it is column not row) and out of them you want to show 5 field right?
are you able to connect API and retrieve all 10 field? if yes if you are showing data using datagrid view then you can do one thing stop auto generate coumn to false
http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.autogeneratecolumns.aspx
now create your own column which you required.
http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.columns.aspx
Please refer more details
http://msdn.microsoft.com/en-us/library/System.Windows.Forms.DataGridView.aspx
hope this will help you.
Dipika Shah102 reputationPosted Jul 9, 2013, 5:16 AM EDT
now i display data on panel not a gridview..
mean in my application i display 5 data(movieId,moviename,movieimg,screen,showtime) on label and this all data are in panel.
i have already API data but i display only above 5 data and i display this data in panel.
Dipika Shah102 reputationPosted Jul 9, 2013, 7:56 AM EDT
Jignesh TrivediRank #16 · 50.3K reputationPosted Jul 9, 2013, 6:46 PM EDT
what is return type of your API function i.e datatable, colloection of class or return any class?
Dipika Shah102 reputationPosted Jul 10, 2013, 3:45 AM EDT
Jignesh TrivediRank #16 · 50.3K reputationPosted Jul 10, 2013, 7:06 PM EDT
Ok, so your return type is class then simply you can assign property of class to lables or text boxes
like....
label1.Text = ClassA.Prop1;
hope this will help you.
Dipika Shah102 reputationPosted Jul 10, 2013, 11:36 PM EDT
it display whole data.
but i will display 5 of them.
plz,tell solution of this.
Jignesh TrivediRank #16 · 50.3K reputationPosted Jul 11, 2013, 12:09 AM EDT
hi,
I am little bit confused about your requirement.
In above post i mean to
MyAPI a =new MyAPI();
var ClassA = A.GetMovieData();
label1.Text = ClassA.movieId;
label2.Text = ClassA.moviename;
label3.Text = ClassA.movieimg; // here you have write special code to show img...
label4.Text = ClassA.screen;
label5.Text = ClassA.showtime;
how you under stand now...