Click here to Skip to main content
15,891,743 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi...
I am fresher in asp.net.
I have one DropDownList(DDLState) and one Textbox(txtCity).

Table(City) has Three Columns:
City_ID
City_Name
State_Id

I want to save value of a textbox(txtCity) in a table(City) based on StateId AND The State_ID is generated by selected value of DropDownList(DDLState). How can i do ?
Pls Help...
Sorry for my English............

Thanks a lot...
Posted

1 solution

You can write simple query for inserting the values in city table as per below.

C#
sqlCommand Cmd= new SqlCommand("Insert into city(City_Name,State_Id) values('"+TextBoxCity.Text+"','"+DropdownListState.selectedValue.ToString()+"')",ConnectionObject);
 
Share this answer
 
Comments
[no name] 17-Apr-13 9:45am    
You could at least warn the OP that doing SQL commands in this manner is an invitation to SQL injection attacks.

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