如何使用asp.net将选中的值从网格视图插入到文本框中 [英] How to insert checked value from grid view into text box using asp.net
问题描述
嗨
我有一个带有gridview的复选框,从数据库加载菜单。
我尝试将menuid存储为基于组的数组
例如。我在Gridview中有10个菜单。我只选择6个菜单中的10个
我只需要复选框值捕获。
1.Subscription
2.客户服务
3.报告
4.续订表格
5.Registration
6.Refund
7.complains日志
8.代理报告
9.Payment Summary
10.详细交易报告
如果我选择1,5,6,8,9,10我需要文本框中的值,如10001101111
检查值= 1且未检查值= 0
请给我建议
Maideen
Hi
I have gridview with check box , which is loaded the menu from database.
I try to store menuid as array based on group
for example. I have 10 menu in Gridview. I select only 6 menu out of 10
I need check box value capture only.
1.Subscription
2.customer service
3.Reports
4.Renewal Form
5.Registration
6.Refund
7.complains Log
8.Reports By Agent
9.Payment Summary
10.Detailed Transaction Report
if i select 1,5,6,8,9,10 I need the value in text box like 10001101111
checked value = 1 and unchecked value = 0
Pls advice me
Maideen
推荐答案
可能你错过了将新值附加到循环中的旧值。试试这个 -
May be you have missed just to append the new value to old value in the loop. Try this-
Dim ch As CheckBox
For i As Integer = 0 To GridView1.Rows.Count - 1
ch = CType(GridView1.Rows(i).FindControl("chk"), CheckBox)
If ch.Checked = True Then
Me.txtPrivCode.Text += "1"
ElseIf ch.Checked = False Then
Me.txtPrivCode.Text += "0"
End If
Next
希望,它有帮助:)
Hope, it helps :)
这篇关于如何使用asp.net将选中的值从网格视图插入到文本框中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!