C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




Combobox selectedvalue error


Posted Date: 30 May 2007      Total Responses: 2

Posted By: Muskan srivastava       Member Level: Silver     Points: 2


Hi,
This is muskan. I have problem in C#.net . I started learning C# . In this context I have following problem. How can I used Selectedvalue of Combobox on page load event. What i want is like I used to use call class function in which 2 value saved. First is ID and Second is UserName. The UserName show in Combobox and when I save the ID saved. But In C# I can not know how to do this. Please help me to do this. I used following Function at Class level:

//
Public Function GetValueInDropDown(ByVal cmbName As DropDownList, ByVal strFirstItem As String, ByVal StorProcName As String, ByVal dbparam As String, ByVal usparam As String, ByVal dbparam1 As String, ByVal usparam1 As String)
Dim ds As New DataSet
ds = Me.GetDataSet(StorProcName, dbparam, usparam, dbparam1, usparam1)
cmbName.Items.Clear()
cmbName.Items.Add(New ListItem(strFirstItem, "0"))
For Each dr As DataRow In ds.Tables(0).Rows
cmbName.Items.Add(New ListItem(dr(1), dr(0)))
Next
End Function

//

And Call this function on load Event like this: //

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If IsPostBack = False Then
obj.GetValueInDropDown(cmbUserLavel, "Select", "sp_Get_UserLavel")
End If
End Sub
This will give result to show UserName but when I saved(cmbUserLabel.selectedvalue) the ID is Saved instead of UserName . Please help me.




Responses

Author: Padma    30 May 2007Member Level: DiamondRating:     Points: 2
so get selectitem.text instead of getting selectedvalue


Author: ChandraShekarThota    27 Jun 2007Member Level: DiamondRating:     Points: 2
use selectitem.text


Post Reply
You must Sign In to post a response.
Next : datagrid items
Previous : Time related....any one please
Return to Discussion Forum
Post New Message
Category: .NET

Related Messages



dotNet Slackers   BizTalk Adaptors    Web Design

conference calls

Contact Us    Privacy Policy    Terms Of Use