I am using radiobutton list with 3 list item, after select one list item its only take null value in database
cmd.Parameters.AddWithValue("@FarmerType", rdltype.SelectedItem.Text);
Sachin SinghPosted Jan 3, 2023, 5:38 AM
Have you manually added the hardcoded value? It seems incorrect it should be like this (If radiobutton is not binding from code behind)
To get text instead,
Rajeesh MenothPosted Jan 3, 2023, 10:04 AM
Hi,
You need to validate the following steps in your code.
1. Make sure what radio button value you are getting it before storing in the database. If you are getting the value in the backend code before storing it, then the issue is related to your database code.
2. Kindly refer to the following article - https://www.c-sharpcorner.com/UploadFile/009464/save-selected-data-of-radio-button-list-in-Asp-Net/
Sachin SinghPosted Jan 3, 2023, 7:34 AM
Do this
and make sure , in database the Type column is Varchar(150)
Garima BansalPosted Jan 3, 2023, 7:17 AM
Sachin Singh
i am using this way but still store null value in database
var selectedValue = rdltype.SelectedItem.Text;
cmd.Parameters.AddWithValue("@Type", selectedValue);