|
I am doing an application in ASP .NET in which i am using a list box with multiple selection. I am using a sqldatasource to bind values to the list box. Everything works fine till this.
i want the page to send the selected multiple values in list box to be in two different text boxes
i tried this code and working, all the selected values comes to single text boxes. I want first selected value to be in textbox1 and second value to be in textbox2..
This is the code...
On Click event of a button
int i;
txt_uname1.Text = "selected" + " ";
for (i = 0; i < list_users.Items.Count - 1; i++)
{
if (list_users.Items[i].Selected)
{
txt_uname1.Text = txt_uname1.Text + list_users.Items[i].Text + " ";
}
}
Please help me fixing this...
Thanks in advance
SAJAN A PILLAI
ASP.NET,C#.NET Programmer
BANGALORE
"Winners don't do different things. They do things differently. ...
|
|
|
|
|
What if user selects more than 3 items from the ListBox ?
Where are you going to show those items ?
Code modification for your logic (Not tested)
int i;
txt_uname1.Text = "selected" + " ";
bool isFirstSelected
for (i = 0; i < list_users.Items.Count - 1; i++)
{
if (list_users.Items[i].Selected)
{
if(!isFirstSelected)
{
//TextBox 1
txt_uname1.Text = list_users.Items[i].Text;
isFirstSelected=true;
}
else
{
//Text Box 2
txt_uname2.Text = list_users.Items[i].Text;
break;
}
}
Thanks and Regards
Sandeep
If If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
Check My Blog
|
|
|
|
|
Thanks for the reply....It works.
SAJAN A PILLAI
ASP.NET,C#.NET Programmer
BANGALORE
"Winners don't do different things. They do things differently. ...
|
|
|
|
|
For that instead of assigning values directly to textbox,first you store values to a string array.And after that you create other loop and assign values to your textboxes.
Hope this will help you
|
|
|
|
|
How to creating application
|
|
|
|
|
Get it
SSK.
Anyone who says sunshine brings happiness has never danced in the rain.
|
|
|
|
|
|
|
hi what for?
SSK.
Anyone who says sunshine brings happiness has never danced in the rain.
|
|
|
|
|
Hi,
I am create a masterpage and webform and I want to display the webform in one page like when we open the website link ,default page, all the contents display in one page,the user no need to scroll up and down.
How to do this using asp.net masterpage or webform?
Anyone can help?
Thanks.
Regards,
Katelva
|
|
|
|
|
put all the contents inside the content place holder and then u can see it.
SSK.
Anyone who says sunshine brings happiness has never danced in the rain.
|
|
|
|
|
Hi,
I have been design my stuff in the webform using masterpage,but when I test using the browser, the user need to scroll down the page to see all the content, I wan to make all the content which user can see in one page?
Regards,
Katelva
|
|
|
|
|
Hi,
I want to drag a panel drop it to another location in the same page.
Just like iGoogle where we can drag and drop the panel from one location to another.
How can I do?
Is there any control in .Net? or Any solution in AJAX?
Thanks
|
|
|
|
|
sjs4u wrote: Is there any control in .Net? or Any solution in AJAX?
Get it
SSK.
Anyone who says sunshine brings happiness has never danced in the rain.
|
|
|
|
|
|
its my pleasure to help.
SSK.
Anyone who says sunshine brings happiness has never danced in the rain.
|
|
|
|
|
|
|
|
Use Ajax for that.
SSK.
Anyone who says sunshine brings happiness has never danced in the rain.
|
|
|
|
|
Hi to all
how to convert to arraylist to dataset, i don't want to add one by one item to dataset by repeating loop.
i want predefined statement to convert Arraylist to dataset
i tried below statement, it is showing error:
DataSet[] ds2 = (DataSet[])arrLst.ToArray(typeof(DataSet));
any suggestions please
This is haneef.............................................................
|
|
|
|
|
Could you tell what are you trying to achieve ?
As you may get better solution than what you are trying
Thanks and Regards
Sandeep
If If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
Check My Blog
|
|
|
|
|
ArrayList arraylistcontainer = new ArrayList(2);
arraylistcontainer.Insert(0, "aa");
arraylistcontainer.Insert(1, "bb");
can you convert this into dataset with out taking any loops.
This is haneef.............................................................
|
|
|
|
|
haneef wrote: can you convert this into dataset with out taking any loops.
I think you can't as implimentation of DataSet is different than ArrayList DataSet Contains DataTable in which you have Rows these Rows are resposible for storing data not Dataset itself.
So you will have to store the ArraList in these rows
public DataSet ConvertArraylistToDataSet(ArrayList arrayList)
{
dsEntityReturned = new DataSet();
dtEntityReturned = new DataTable();
dsEntityReturned.Tables.Add(dtEntityReturned);
dsEntityReturned.Tables[0].Columns.Add("NAME", System.Type.GetType("System.Object"));
foreach (object obj in arrayList)
{
DataRow rows = dsEntityReturned.Tables[0].NewRow();
rows[0] =obj; // here the error blows up
dsEntityReturned.Tables[0].Rows.Add(rows);
return dsEntityReturned;
}
return null;
}
Thanks and Regards
Sandeep
If If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
Check My Blog
|
|
|
|
|