Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

string convert

Status
Not open for further replies.

goransaler

IS-IT--Management
Mar 6, 2003
56
SE
hello
i´m trying to pass a stringvalue when i display some data
If i have a string named ViewTablename
and like to do this
the string value is for example "company"

this.MainlistBox3.DisplayMember = "company.Name";
but i like to use the string
how do i do

this.MainlistBox3.DisplayMember = ViewTablename + ".Name";

or what

thanks
 
Please someone.
Maybee i am way out
I´m a newbee and i have orderd a book how to start
but meanvile i´m hungry to try
 
Code:
string CompanyName = "company";

this.MainlistBox3.DisplayMember = CompanyName;
will cause the listbox to display the company column from your datasource.

Chip H.


If you want to get the best response to a question, please check out FAQ222-2244 first
 
Hello
yes but the tablename is Company and the column is namme
i like to bas the tablename in string but columnname always the same

string CompanyName = "company";

this.MainlistBox3.DisplayMember = CompanyName + ".name";

i have tables with links (constraints)
so it can be like this

lets say table company
and table Order and table Contact

and links (constraints)

this.MainlistBox3.DisplayMember = "Company.CompanyContakt.name";


or

this.MainlistBox3.DisplayMember = "Order.OrderContakt.name";

but instead i like to pass a string with either "Company" or "Order" and put it in one command

string TableName = "company";
this.MainlistBox3.DisplayMember = TableName.TableName + "Contakt.name";


i dont know how this will be

 
The code below is called to initialize a listbox from a DataTable object , DisplayMember and ValueMember passed as parameters:
private void InitializeListBox2(string sTable, string
DataSet ds = ;
sDisplayMember, string sValueMember)
{
this.listBox1.DataSource = ds.Tables[sTable];
this.listBox1.DisplayMember = sDisplayMember ;
this.listBox1.ValueMember = sValueMember;
}
Of course you have to check if the sTable is part of the DataSet and the sDisplayMember and sValueMember are valid columns in the sTable.
-obislavu-
 
Thanks that helped me
I´m using VS.net so those initially fix themselves

but this was further in the code
i did like this

private void MainlistBoxView(string ViewTablename)
{
string ViewTblnametot;
ViewTblnametot = ViewTablename + ".Name";
this.MainlistBox.DisplayMember = ViewTblnametot;

}

and i call it like this
lets say ViewTablename = "Company"


i can run like this
MainlistBoxView(ViewTablename);

by the way
i understand DataSource and DisplayMember.
but not Valuemember what is Valuemember
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top