GRChandrashekar
asked on
adding blank row to datasource
Hi,
I am populating combobox from two tables with following query
private void Fillcmbbankerid()
{
try
{
{
prefetchPathbanker.Add(Ban kerEntity. PrefetchPa thBank);
bucketbanker.PredicateExpr ession.Add (BankerFie lds.Flag ==
StandardFlag.recordvalidfl ag);
adapterbanker.FetchEntityC ollection( datasource banker, bucketbanker, 0,
new SortExpression(BankerField s.BankerId |
SortOperator.Ascending),
prefetchPathbanker);
cmbbankerid.DataSource = datasourcebanker;
cmbbankerid.DisplayMember = "DESCRIPTION";
cmbbankerid.ValueMember = "BANKERID";
cmbbankerid.SelectedIndex = -1;
}
}
catch (Exception ex)
{
GlobalErrorHandler.LogMess age(ex.Mes sage + ex.StackTrace);
}
finally
{
adapterbanker.CloseConnect ion();
}
}
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
I am populating combobox from two tables with following query
private void Fillcmbbankerid()
{
try
{
{
prefetchPathbanker.Add(Ban
bucketbanker.PredicateExpr
StandardFlag.recordvalidfl
adapterbanker.FetchEntityC
new SortExpression(BankerField
SortOperator.Ascending),
prefetchPathbanker);
cmbbankerid.DataSource = datasourcebanker;
cmbbankerid.DisplayMember = "DESCRIPTION";
cmbbankerid.ValueMember = "BANKERID";
cmbbankerid.SelectedIndex = -1;
}
}
catch (Exception ex)
{
GlobalErrorHandler.LogMess
}
finally
{
adapterbanker.CloseConnect
}
}
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
ASKER
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.
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.
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.
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.
ASKER
Would you please explain this
insertAt method
insertAt method
sorry it is Insert Method
cmbbankerid.Items.Insert(0 , "None");
cmbbankerid.Items.Insert(d atasourceb anker.Leng th, "All");
cmbbankerid.Items.Insert(0
cmbbankerid.Items.Insert(d
ASKER
This line does not work
datasourcebanker.Length
datasourcebanker.Length
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.
ASKER
it is basically datasource which am using like cmbbankerid.DataSource = datasourcebanker;
Not sure what i have to select instead of length
Not sure what i have to select instead of length
ASKER
I get option datasourcebanker(int index,object item)
So what to write ?
So what to write ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
datasource banker is just an entity collection
ASKER
which am using like
private readonly EntityCollection datasourcebanker =
new EntityCollection(new BankerEntityFactory());
private readonly EntityCollection datasourcebanker =
new EntityCollection(new BankerEntityFactory());
you can use count property for this.
ASKER
How ? I just need to add an empty row with index 0
http://www.tek-tips.com/faqs.cfm?fid=5281