问题描述
在我的场景中,我必须在表单中显示一个问题及其选择,用户必须选择一个选项,我想将选中的选项保存到数据库中。
i有一个radiobuttonlist受限制选择文本。当用户点击提交按钮时,我想通过使用this.RadioButtonlist1.SelectedIndex.toString()来保存所选文本。
但它无法正常工作我得到保存在数据库中的无线电按钮的索引但是不是文本我怎么能解决这个问题,请提前帮助我,并提前了解..
in my scenario i have to display a question and its choices in a form and user has to pick one option and i want to save the picked option into database.
i have a radiobuttonlist which is bound to the choices text. when user clicks submit button i want to save the text of choice by using "this.RadioButtonlist1.SelectedIndex.toString()"
but it is not working i get index of the radiobutton saved into the database but not the text how i can solve this problem please help me and thnks a lot in advance..
推荐答案
RadioButtonList1.SelectedValue.ToString();
this.RadioButtonlist1.SelectedIndex.toString()
with
with
this.RadioButtonlist1.SelectedItem.Value;
这可能会有所帮助。
This may help.
rbtn.DataSource = dt;
rbtn.DataValueField = "Userid";
rbtn.DataTextField = "User_Name";
rbtn.DataBind();
然后使用
获取所选文字br />
then get the selected text using
string selectedText = rbtn.SelectedItem.Value;
这篇关于在数据库中保存radiobuttonlist文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!