[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

adding blank row to datasource

Posted on 2010-08-30
14
Medium Priority
?
422 Views
Last Modified: 2012-05-10
Hi,

I am populating combobox from two tables with following query

private void Fillcmbbankerid()
        {
            try
            {
                {
                    prefetchPathbanker.Add(BankerEntity.PrefetchPathBank);
                    bucketbanker.PredicateExpression.Add(BankerFields.Flag ==
                                                         StandardFlag.recordvalidflag);
                    adapterbanker.FetchEntityCollection(datasourcebanker, bucketbanker, 0,
                                                        new SortExpression(BankerFields.BankerId |
                                                                           SortOperator.Ascending),
                                                        prefetchPathbanker);
                    cmbbankerid.DataSource = datasourcebanker;
                    cmbbankerid.DisplayMember = "DESCRIPTION";
                    cmbbankerid.ValueMember = "BANKERID";
                    cmbbankerid.SelectedIndex = -1;
                }
            }
            catch (Exception ex)
            {
                GlobalErrorHandler.LogMessage(ex.Message + ex.StackTrace);
            }
            finally
            {
                adapterbanker.CloseConnection();
            }
        }

Output of query what I have written is SELECT   BANK.DESCRIPTION, BANKER.BANKER_ID
  FROM   BANKER, BANK
 WHERE   (BANK.BANK_ID = BANKER.BANK_ID) AND (BANKER.FLAG = 0)

Problem
Now the question is how to i add a blank row to this datasource. ?
Remember, I am using two tables here
0
Comment
Question by:GRChandrashekar
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 5
14 Comments
 
LVL 53

Expert Comment

by:Dhaest
ID: 33558320
Do you want an empty item added to the combobox or what exactly do you want ?

http://www.tek-tips.com/faqs.cfm?fid=5281
0
 

Author Comment

by:GRChandrashekar
ID: 33558349
Well I know how to add an empty Item

The problem is adding an empty item when I am loading combobox with relations from 2 tables as stated in my query under my question.
0
 
LVL 9

Expert Comment

by:puru1981
ID: 33558581
it is possible to do but you need to use union for this. where you can write a select query which will return a single blank row.

but its better to use it this way because it will be scalable.

you can use combobox insertAt method to add an empty item because from the select query it would be not possible.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:GRChandrashekar
ID: 33558588
Would you please explain this

insertAt method
0
 
LVL 9

Expert Comment

by:puru1981
ID: 33558700
sorry it is Insert Method
 
cmbbankerid.Items.Insert(0, "None");
        cmbbankerid.Items.Insert(datasourcebanker.Length, "All");
0
 

Author Comment

by:GRChandrashekar
ID: 33558909
This line does not work
datasourcebanker.Length
0
 
LVL 9

Expert Comment

by:puru1981
ID: 33559030
i don't know the datatype of datasourcebanker so i written that. basic purpose was to insert the index. i thought it was an array so used Length. you can use appropriately.
0
 

Author Comment

by:GRChandrashekar
ID: 33559083
it is basically datasource which am using like  cmbbankerid.DataSource = datasourcebanker;

Not sure what i have to select instead of length
0
 

Author Comment

by:GRChandrashekar
ID: 33559137
I get option       datasourcebanker(int index,object item)

So what to write ?
0
 
LVL 9

Accepted Solution

by:
puru1981 earned 2000 total points
ID: 33559264
just remove this line. i have used it to insert a row at the end of the combobox.

alternatively, provide me the datatype of datasourcebanker.
0
 

Author Comment

by:GRChandrashekar
ID: 33559333
datasource banker is just an entity collection
0
 

Author Comment

by:GRChandrashekar
ID: 33559342
which am using like
private readonly EntityCollection datasourcebanker =
            new EntityCollection(new BankerEntityFactory());
0
 
LVL 9

Expert Comment

by:puru1981
ID: 33559507
you can use count property for this.
0
 

Author Comment

by:GRChandrashekar
ID: 33564144
How ? I just need to add an empty row with index 0
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question