datagridview
-
i am using windows aplliction using c#... i have 1000 records in my table.... which has fields CUSTOMER_ID,NAME,CITY,SALARY..... I HAVE TO SEE ONLY THE CUSTOMER WHO ARE LIVING THE CITY CALLED "DOWNTOWN" HOW CAN I SEE THIS IN DATAGRIDVIEW... PLS REPLY... GIVE ME SUGGESTION OR SAMPLE CODING... THNX IN ADVANCE
-
i am using windows aplliction using c#... i have 1000 records in my table.... which has fields CUSTOMER_ID,NAME,CITY,SALARY..... I HAVE TO SEE ONLY THE CUSTOMER WHO ARE LIVING THE CITY CALLED "DOWNTOWN" HOW CAN I SEE THIS IN DATAGRIDVIEW... PLS REPLY... GIVE ME SUGGESTION OR SAMPLE CODING... THNX IN ADVANCE
-
i am using windows aplliction using c#... i have 1000 records in my table.... which has fields CUSTOMER_ID,NAME,CITY,SALARY..... I HAVE TO SEE ONLY THE CUSTOMER WHO ARE LIVING THE CITY CALLED "DOWNTOWN" HOW CAN I SEE THIS IN DATAGRIDVIEW... PLS REPLY... GIVE ME SUGGESTION OR SAMPLE CODING... THNX IN ADVANCE
Hi, Why don't you use the BindingSource Filter property? For example, you can have myDataSource.Filter = "City = 'DOWNTOWN'" Here is the example from MSDN: private void PopulateDataViewAndFilter() { DataSet set1 = new DataSet(); // Some xml data to populate the DataSet with. string musicXml = "" + "" + "ColdplayX&Y" + "Dave MatthewsUnder the Table and Dreaming" + "Dave MatthewsLive at Red Rocks" + "Natalie MerchantTigerlily" + "U2How to Dismantle an Atomic Bomb" + ""; // Read the xml. StringReader reader = new StringReader(musicXml); set1.ReadXml(reader); // Get a DataView of the table contained in the dataset. DataTableCollection tables = set1.Tables; DataView view1 = new DataView(tables[0]); // Create a DataGridView control and add it to the form. DataGridView datagridview1 = new DataGridView(); datagridview1.AutoGenerateColumns = true; this.Controls.Add(datagridview1); // Create a BindingSource and set its DataSource property to // the DataView. BindingSource source1 = new BindingSource(); source1.DataSource = view1; // Set the data source for the DataGridView. datagridview1.DataSource = source1; source1.Filter = "artist = 'Dave Matthews'"; }
Regards, Lev
-
on load of the screen or where ever you are loading the grid just before binding to the dataGrid you can loop through each row and check the condtion where Rows[0].Cells[0].tostring()=="xyz"
vikas da
:wtf: are you insane? I would hate to see crap like that in a program i have to maintain...
Harvey Saayman - South Africa Junior Developer .Net, C#, SQL
you.suck = (you.Passion != Programming & you.Occupation == jobTitles.Programmer)
1000100 1101111 1100101 1110011 100000 1110100 1101000 1101001 1110011 100000 1101101 1100101 1100001 1101110 100000 1101001 1101101 100000 1100001 100000 1100111 1100101 1100101 1101011 111111 -
i am using windows aplliction using c#... i have 1000 records in my table.... which has fields CUSTOMER_ID,NAME,CITY,SALARY..... I HAVE TO SEE ONLY THE CUSTOMER WHO ARE LIVING THE CITY CALLED "DOWNTOWN" HOW CAN I SEE THIS IN DATAGRIDVIEW... PLS REPLY... GIVE ME SUGGESTION OR SAMPLE CODING... THNX IN ADVANCE
Assuming the 1000 rows are coming from a data base, you have two options... 1) Query only the data your looking for and not everything, remember "any monkey can
SELECT * FROM
2) Use a DataView to filter out the data you want to displayHarvey Saayman - South Africa Junior Developer .Net, C#, SQL
you.suck = (you.Passion != Programming & you.Occupation == jobTitles.Programmer)
1000100 1101111 1100101 1110011 100000 1110100 1101000 1101001 1110011 100000 1101101 1100101 1100001 1101110 100000 1101001 1101101 100000 1100001 100000 1100111 1100101 1100101 1101011 111111 -
:wtf: are you insane? I would hate to see crap like that in a program i have to maintain...
Harvey Saayman - South Africa Junior Developer .Net, C#, SQL
you.suck = (you.Passion != Programming & you.Occupation == jobTitles.Programmer)
1000100 1101111 1100101 1110011 100000 1110100 1101000 1101001 1110011 100000 1101101 1100101 1100001 1101110 100000 1101001 1101101 100000 1100001 100000 1100111 1100101 1100101 1101011 111111 -
are you mental.. go to some hospital..:) bloddy this was just a suggestion if you know something better then me .. did i stop you to answer...
vikas da
tasumisra wrote:
did i stop you to answer
Nope, but there are much easier ways :) see my reply...
Harvey Saayman - South Africa Junior Developer .Net, C#, SQL
you.suck = (you.Passion != Programming & you.Occupation == jobTitles.Programmer)
1000100 1101111 1100101 1110011 100000 1110100 1101000 1101001 1110011 100000 1101101 1100101 1100001 1101110 100000 1101001 1101101 100000 1100001 100000 1100111 1100101 1100101 1101011 111111 -
tasumisra wrote:
did i stop you to answer
Nope, but there are much easier ways :) see my reply...
Harvey Saayman - South Africa Junior Developer .Net, C#, SQL
you.suck = (you.Passion != Programming & you.Occupation == jobTitles.Programmer)
1000100 1101111 1100101 1110011 100000 1110100 1101000 1101001 1110011 100000 1101101 1100101 1100001 1101110 100000 1101001 1101101 100000 1100001 100000 1100111 1100101 1100101 1101011 111111I have seen your answer ... but some times we can't hardcode any querry from sql command it will cost more if u need to change your condition. anyway if you have ever used WCF then in services we are binding the reader object with our business object for each row that time we can filter it out more easily...
vikas da
-
I have seen your answer ... but some times we can't hardcode any querry from sql command it will cost more if u need to change your condition. anyway if you have ever used WCF then in services we are binding the reader object with our business object for each row that time we can filter it out more easily...
vikas da
tasumisra wrote:
some times we can't hardcode any querry
In that case, create a stored procedure for SQL and call that in your application... problem solved :) OR Use the DataView object, i use this frequently to filter data dynamically
Harvey Saayman - South Africa Junior Developer .Net, C#, SQL
you.suck = (you.Passion != Programming & you.Occupation == jobTitles.Programmer)
1000100 1101111 1100101 1110011 100000 1110100 1101000 1101001 1110011 100000 1101101 1100101 1100001 1101110 100000 1101001 1101101 100000 1100001 100000 1100111 1100101 1100101 1101011 111111 -
i am using windows aplliction using c#... i have 1000 records in my table.... which has fields CUSTOMER_ID,NAME,CITY,SALARY..... I HAVE TO SEE ONLY THE CUSTOMER WHO ARE LIVING THE CITY CALLED "DOWNTOWN" HOW CAN I SEE THIS IN DATAGRIDVIEW... PLS REPLY... GIVE ME SUGGESTION OR SAMPLE CODING... THNX IN ADVANCE
as mentioned use the filter option or change the query to have a where clause. but FYI. THE USE OF CAPITALS is considered shouting in forums. :-D
V.
Stop smoking so you can: Enjoy longer the money you save. Moviereview Archive -
tasumisra wrote:
some times we can't hardcode any querry
In that case, create a stored procedure for SQL and call that in your application... problem solved :) OR Use the DataView object, i use this frequently to filter data dynamically
Harvey Saayman - South Africa Junior Developer .Net, C#, SQL
you.suck = (you.Passion != Programming & you.Occupation == jobTitles.Programmer)
1000100 1101111 1100101 1110011 100000 1110100 1101000 1101001 1110011 100000 1101101 1100101 1100001 1101110 100000 1101001 1101101 100000 1100001 100000 1100111 1100101 1100101 1101011 111111 -
Harvey Saayman wrote:
In that case, create a stored procedure for SQL and call that in your application... problem solved
what if you dont have acess to the stored proc....??? :) its written in COBOL and residing in Mainframe...
vikas da
tasumisra wrote:
COBOL
Then you get your ass out of the C# forum :laugh:
Harvey Saayman - South Africa Junior Developer .Net, C#, SQL
you.suck = (you.Passion != Programming & you.Occupation == jobTitles.Programmer)
1000100 1101111 1100101 1110011 100000 1110100 1101000 1101001 1110011 100000 1101101 1100101 1100001 1101110 100000 1101001 1101101 100000 1100001 100000 1100111 1100101 1100101 1101011 111111 -
tasumisra wrote:
COBOL
Then you get your ass out of the C# forum :laugh:
Harvey Saayman - South Africa Junior Developer .Net, C#, SQL
you.suck = (you.Passion != Programming & you.Occupation == jobTitles.Programmer)
1000100 1101111 1100101 1110011 100000 1110100 1101000 1101001 1110011 100000 1101101 1100101 1100001 1101110 100000 1101001 1101101 100000 1100001 100000 1100111 1100101 1100101 1101011 111111 -
do you know ?????? a stored proc can be written in COBOL.. and sorry you can acess these stored proc using your ass..from C# also
vikas da
Calm d0wn dude, i was JOKING... sheesh
Harvey Saayman - South Africa Junior Developer .Net, C#, SQL
you.suck = (you.Passion != Programming & you.Occupation == jobTitles.Programmer)
1000100 1101111 1100101 1110011 100000 1110100 1101000 1101001 1110011 100000 1101101 1100101 1100001 1101110 100000 1101001 1101101 100000 1100001 100000 1100111 1100101 1100101 1101011 111111