DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/)
-   ASP.NET (http://www.daniweb.com/forums/forum18.html)
-   -   Could someone help me how to add value to A item based on other selected value??(c#) (http://www.daniweb.com/forums/thread113473.html)

hwa Mar 12th, 2008 3:28 am
Could someone help me how to add value to A item based on other selected value??(c#)
 
My problem is I want to add in a value to a LABEL based on selected value in the DropDownList !!


Example:

tbl_abc

ID Sequence Name
-----------------------------------------------
1 2 Michael
2 3 Jenny
3 4 Max
4 4 Max
5 2 Michael
6 4 Max
7 3 Jenny
8 5 Alice
-----------------------------------------------

ID-(asp:label)
Sequence-(asp:label)
Name-(asp:DropDownList)


-If I choose Max from the DropDownList then the Sequence_label will automatically generate the 4.
-If I choose Michael from the DropDownLst then the Sequence_label will automatically generate the 2.


Can anyone help me to solve this problem??

Thanks in advance !!

sbv Mar 12th, 2008 3:38 am
Re: Could someone help me how to add value to A item based on other selected value??(c#)
 
Hi
You can do this on change event of Ur DropdownList.

Like
on DD1.selectedindex_chnged()
if DD1.selectedvalue == 1 then
{
lbl1.text = DD1.selectedValue()
}

Try this and if need more help then i am here.

Best Luck.

hwa Mar 12th, 2008 3:50 am
Re: Could someone help me how to add value to A item based on other selected value??(c#)
 
Hi sbv,

If I follow the your statement then I only can get the drop down list value and add into the label but what I want is not this.

I want is like this that I mentioned above:
-If I choose Max from the DropDownList then the Sequence_label will automatically generate the 4.
-If I choose Michael from the DropDownLst then the Sequence_label will automatically generate the 2.


Thanks ya

sbv Mar 12th, 2008 3:58 am
Re: Could someone help me how to add value to A item based on other selected value??(c#)
 
hi hwa,
ok. But the meathod i told is right.
You can assign any value to label using this.
Is all values are in Db table? If yes then fetch it as per Records selected in DropDown.
As... on Selected index change.
fire a query something like...

"select Squesnce from tbl_abc where ID = " + DD1.Selectedvalue

and assign its value to label.

Now i have given right solution or still not. Still you need something different ?
If so then i am sorry. I am not clear with your requirement.

Have a good time. Bye.

SheSaidImaPregy Mar 12th, 2008 2:26 pm
Re: Could someone help me how to add value to A item based on other selected value??(c#)
 
you can do it by exactly what he said. An example of this would be:
labelname.Text = dropdownlistname.SelectedItem.Value

hwa Mar 12th, 2008 9:50 pm
Re: Could someone help me how to add value to A item based on other selected value??(c#)
 
Quote:

Originally Posted by SheSaidImaPregy (Post 559240)
you can do it by exactly what he said. An example of this would be:
labelname.Text = dropdownlistname.SelectedItem.Value




Hi,

-May I know that this code only can retrieve the selected value in DropDown to the Label right???

-Actually is my misunderstanding or yours not clear about my requirement??

-the data inside tbl_abc is fix !!

-sorry, can yours give more clearly about that

Thanks ya

hwa Mar 12th, 2008 11:07 pm
Re: Could someone help me how to add value to A item based on other selected value??(c#)
 
Hi sbv,

Can you explain more clearly about it because I still confuse about it.

-I retrieve the tbl_abc from sqlDatabase
-I using SqlDataSource(is it needed??)
-I using <asp:Label> for the Sequence (this label will show the value based on the Selected value in the DropDown)
-I using <asp:DropDownList> for the Name (this will choose by the user)

All I do is in the <InsertItemTemplate>


Thanks for give me a hand !!

sbv Mar 13th, 2008 1:03 am
Re: Could someone help me how to add value to A item based on other selected value??(
 
Quote:

Originally Posted by hwa (Post 558684)
My problem is I want to add in a value to a LABEL based on selected value in the DropDownList !!


Example:

tbl_abc

ID Sequence Name
-----------------------------------------------
1 2 Michael
2 3 Jenny
3 4 Max
4 4 Max
5 2 Michael
6 4 Max
7 3 Jenny
8 5 Alice
-----------------------------------------------

ID-(asp:label)
Sequence-(asp:label)
Name-(asp:DropDownList)


-If I choose Max from the DropDownList then the Sequence_label will automatically generate the 4.
-If I choose Michael from the DropDownLst then the Sequence_label will automatically generate the 2.


Can anyone help me to solve this problem??

Thanks in advance !!





Hi,

Do you want to assign ID and Sequence values both to the label depending upon the selection of DropDownLst?
Quote:

As you said here -
ID-(asp:label)
Sequence-(asp:label)
Name-(asp:DropDownList)

I consider yes.

As i told you in my last post. On DropDownList's selected index change event
you need to do 2 things.
1) fetch ID and Sequence from db depending upon the DropdownLst value
2) Then assign it to your labels.

hwa Mar 13th, 2008 2:43 am
Re: Could someone help me how to add value to A item based on other selected value??(c#)
 
Thanks all

I had solve my problem. Yours are right.
Thats all is my mistake


Thanks very very much

srikanthkadem Mar 14th, 2008 7:00 am
Re: Could someone help me how to add value to A item based on other selected value??(c#)
 

hi


All times are GMT -4. The time now is 11:16 pm.

Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC