Click here to Skip to main content
15,892,746 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am writing the string like this:
string qry = "Insert into SchoolBranch (BranchCode,City,State,Country,SchoolCode) values ('"+Sbranchcode.Text+"','"+SbranchCity.Text+"','"+Sbranhstate.Text+"','"+SbranchCountry.Text+"','"+BSchoolCode.SelectedItem+"')";
        BusinessLogic.executqry(qry);

but it is selected only 0 index value all the time...so can you give the right solutions.
Posted
Comments
bhagirathimfs 23-Aug-12 5:19am    
Please explain your question briefly ...
ankur15 23-Aug-12 5:22am    
i m writing this code on the submit click event but in data base only index[0] value is submitting..
bhagirathimfs 23-Aug-12 9:26am    
you want to store dropdown values into the database or retrieve database values into the dropdown????
Mac12334 24-Aug-12 1:53am    
Please share your code..

I thing You Bind the Dropdown in !postBack Event

in Page Load Event

if(!ispostback)
{
   // Bind your Dropdown
}

then Try to Execute Queryyy
 
Share this answer
 
try this
if your Drop Down list contains only the Schoolcode as the display member,simply use the code,
C#
string qry = "Insert into SchoolBranch (BranchCode,City,State,Country,SchoolCode) values ('"+Sbranchcode.Text+"','"+SbranchCity.Text+"','"+Sbranhstate.Text+"','"+SbranchCountry.Text+"','"+BSchoolCode.Text+"')";
        BusinessLogic.executqry(qry);



You can get the selected text value of a combo box by simply using the Text property of Combo box.

eg:
C#
string s=cmbComboBox.Text;
 
Share this answer
 
v4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900