0
我想從5個文本框的值中取得迴應,然後將它們放入一個字符串中,並最終將它們存儲在數據庫中,但是我無法讓程序構建字符串, 這是我迄今爲止建立字符串的代碼。從文本框和Concat拉入字符串w /分隔符
VB.Code
Dim QuestionANS As String
' Get values from the text boxes
Dim PassA As TextBox = CType(form1.FindControl("A"), TextBox)
Dim PassB As TextBox = CType(form1.FindControl("B"), TextBox)
Dim PassC As TextBox = CType(form1.FindControl("C"), TextBox)
Dim PassD As TextBox = CType(form1.FindControl("B"), TextBox)
Dim PassE As TextBox = CType(form1.FindControl("E"), TextBox)
Dim PassF As TextBox = CType(form1.FindControl("F"), TextBox)
QuestionANS = PassA.Text + "|" + PassB.Text + "|" + PassC.Text + "|" + PassD.Text + "|" + PassE.Text + "|" + PassF.Text
ASP代碼
<asp:DataList runat="server" ID="Questions">
<ItemTemplate>
<table cellpadding="2px" cellspacing="0" border="0" style="page-break- inside:avoid;">
<tr>
<td valign="top" style="padding-right:18px;"><asp:Label runat="server" ID="QuestionNumber" /></td>
<td><asp:Image runat="server" style = "padding: 15px 0px 25px 0px;" ID="Image" /></td>
</tr>
<tr>
<td></td>
<td style="padding-top:10px;padding-bottom:15px;"></td>
<td style="padding-top:10px;padding-bottom:15px;"></td>
<tr>
<td style="width:50px;"><a>A:</a></td><td><asp:TextBox id="A" columns="30" runat="server" /></td>
</tr>
<tr>
<td style="width:50px;"><a>B:</a></td> <td><asp:TextBox id="B" columns="30" runat="server" /></td>
</tr>
<tr>
<td style="width:50px;"><a>C:</a></td><td><asp:TextBox id="C" columns="30" runat="server" /></td>
</tr>
<tr>
<td style="width:50px;"><a>D:</a></td><td><asp:TextBox id="D" columns="30" runat="server" /></td>
</tr>
<tr>
<td style="width:50px;"><a>E:</a></td><td><asp:TextBox id="E" columns="30" runat="server" /></td>
</tr>
<tr>
<td style="width:50px;"><a>F:</a></td><td><asp:TextBox id="F" columns="30" runat="server" /></td>
</tr>
</tr>
</table>
<asp:HiddenField runat="server" ID="QuestionID" />
</ItemTemplate>
</asp:DataList>
你會得到一個異常,如果是,哪個和哪裏? –
QuestionANS =的NullReference,我添加了一個手錶,並沒有任何值從窗體傳回,但似乎正確地引用了 – user1902540
你在哪裏試圖找到控件以及這些控件在哪裏?你已經展示了一些aspx,但是不清楚這些文本框是否與'GridView'中的'NamingContainer'不同。 –