在数据库中保存radiobuttonlist文本 [英] saving radiobuttonlist text in database

查看:69
本文介绍了在数据库中保存radiobuttonlist文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的场景中,我必须在表单中显示一个问题及其选择,用户必须选择一个选项,我想将选中的选项保存到数据库中。

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..

推荐答案

改为使用:



Use this instead:

RadioButtonList1.SelectedValue.ToString();


替换

Replace
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文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆