Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 将值添加到文本='<;%#绑定(";txt_case_num";)%>;_Asp.net_Vb.net_Forms - Fatal编程技术网

Asp.net 将值添加到文本='<;%#绑定(";txt_case_num";)%>;

Asp.net 将值添加到文本='<;%#绑定(";txt_case_num";)%>;,asp.net,vb.net,forms,Asp.net,Vb.net,Forms,这是我的整个网络表单,你可以看到我做了什么。我希望能够将generatePassword(6)的值放入我的db表中的:InsertCommand=“INSERT into utcasesTest(由用户id、状态id、关键性id、项目id、案例编号等创建的)字段中 <%@ Page Language="VB" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org

这是我的整个网络表单,你可以看到我做了什么。我希望能够将generatePassword(6)的值放入我的db表中的:InsertCommand=“INSERT into utcasesTest(由用户id、状态id、关键性id、项目id、案例编号等创建的)字段中

<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
'Our Function generatePassword accepts one parameter 'passwordLength'
'passwordLength will obviously determine the password length.
'The aplhanumeric character set is assigned to the variable sDefaultChars
Function generatePassword(passwordLength)

  'Declare variables
   Dim sDefaultChars
   Dim iCounter
   Dim sMyPassword
   Dim iPickedChar
   Dim iDefaultCharactersLength
   Dim iPasswordLength

   'Initialize variables
   sDefaultChars = "abcdefghijklmnopqrstuvxyzABCDEFGHIJKLMNOPQRSTUVXYZ0123456789"
   iPasswordLength = passwordLength
   iDefaultCharactersLength = Len(sDefaultChars)
   Randomize() 'initialize the random number generator

   'Loop for the number of characters password is to have
   For iCounter = 1 To iPasswordLength
      'Next pick a number from 1 to length of character set 
      iPickedChar = Int((iDefaultCharactersLength * Rnd) + 1)

      'Next pick a character from the character set using the random number iPickedChar
      'and Mid function
       sMyPassword = sMyPassword & Mid(sDefaultChars, iPickedChar, 1)
   Next

   generatePassword = sMyPassword
End Function
</script>

<script runat="server" type="text/vb">
Sub FormView1_Item_Inserted(ByVal sender As Object, ByVal e As FormViewInsertedEventArgs)

    Response.Redirect("ThankYou.asp")
End Sub

Protected Sub FormView1_PageIndexChanging(sender As Object, e As System.Web.UI.WebControls.FormViewPageEventArgs)

End Sub

Protected Sub SqlDataSource1_Selecting(sender As Object, e As System.Web.UI.WebControls.SqlDataSourceSelectingEventArgs)

End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
  .style1 
  {
      width: 100%;
  }
</style>
</head>

<body>
<!-- Input Form-->
<form id="form1" runat="server" method="post">
  <div>
    <asp:FormView ID="FormView1" runat="server" 
                  DataKeyNames="case_id"
                  DataSourceID="SqlDataSource_OC" 
                  DefaultMode="Insert" 
                  OnItemInserted="formview1_Item_Inserted"
                  onpageindexchanging="FormView1_PageIndexChanging">
      <InsertItemTemplate>
        <table>
          <tr>
            <td>criticality_id:</td>
            <td>
              <asp:DropDownList ID="criticality_idTextBox" 
                                runat="server" 
                                Text='<%# Bind("txt_criticality_id","{0:D}") %>' 
                                DataSourceID="SqlDataSource_Criticality" 
                                DataTextField="ut_value"
                                DataValueField="criticality_id"
                                AppendDataBoundItems="true">
                <asp:ListItem Value="0" 
                              Text="--Select Level--" 
                              Selected="True" />
              </asp:DropDownList>
              <br />
            </td>
          </tr>
          <tr>
            <td>case_num:</td>
            <td>
              <asp:TextBox Name="txt_case_num" 
                           ID="case_numTextBox" 
                           runat="server"
                           Text='<%# Bind("txt_case_num") %>' /> **<------ This is the textbox the value needs to go into. It will be hidden so the user wont see it**
              <br />
            </td>
          </tr>
          <tr>
            <td>title:</td>
            <td>
              <asp:TextBox ID="titleTextBox" 
                           runat="server" 
                           Text='<%# Bind("txt_title") %>' />
              <br />
            </td>
          </tr>
          <tr>
            <td>description:</td>
            <td>
              <asp:TextBox ID="descriptionTextBox" 
                           runat="server" 
                           Text='<%# Bind("txt_description") %>' TextMode="MultiLine" />
              <br />
            </td>
          </tr>
          <tr>
            <td>external_email_address:</td>
            <td>    
              <asp:TextBox ID="external_email_addressTextBox" 
                           runat="server"
                           Text='<%# Bind("txt_external_email_address") %>' />
              <br />
            </td>
          </tr>
        </table>
        <asp:LinkButton ID="InsertButton" 
                        runat="server" 
                        CausesValidation="True"
                        CommandName="Insert" Text="Insert" />
        &nbsp;<asp:LinkButton ID="InsertCancelButton" 
                              runat="server" 
                              CausesValidation="False" 
                              CommandName="Cancel" 
                              Text="Cancel" />
      </InsertItemTemplate>
    </asp:FormView>
    <!--Datasource-->
    <asp:SqlDataSource ID="SqlDataSource_OC" 
                       runat="server"
                       ConnectionString="<%$ ConnectionStrings:OC_ConnectionString %>" 
                       InsertCommand="INSERT INTO utcasesTest(created_by_user_id, status_id, criticality_id, project_id, case_num, is_active, description, title, created_by_timestamp, modified_by_timestamp, modified_by_user_id, is_external, external_email_address, object_id, object_type_id) VALUES (@txt_created_by_user_id, @txt_status_id, @txt_criticality_id, @txt_project_id, @txt_case_num, @txt_case_num  **<-------This is where the value is passed to the DB**, @txt_description, @txt_title, getdate(), getdate(), @txt_modified_by_user_id, @txt_is_external, @txt_external_email_address, @txt_object_id, @txt_object_type_id)" 
                       SelectCommand="SELECT utcasesTest.* FROM utcasesTest">
      <InsertParameters>
        <asp:Parameter Name="txt_created_by_user_id" DefaultValue="1" />
        <asp:Parameter Name="txt_status_id" DefaultValue="1" />
        <asp:Parameter Name="txt_criticality_id" />
        <asp:Parameter Name="txt_project_id" DefaultValue="1" />
        <asp:Parameter Name="txt_case_num" />  **<----------Paramater Definition**
        <asp:Parameter Name="txt_is_active" DefaultValue="Y" />
        <asp:Parameter Name="txt_description" />
        <asp:Parameter Name="txt_title" />
        <asp:Parameter Name="txt_created_by_timestamp" />
        <asp:Parameter Name="txt_modified_by_timestamp" />
        <asp:Parameter Name="txt_modified_by_user_id" DefaultValue="1" />
        <asp:Parameter Name="txt_is_external" DefaultValue="Y" />
        <asp:Parameter Name="txt_external_email_address" />
        <asp:Parameter Name="txt_object_id" DefaultValue="-1" />
        <asp:Parameter Name="txt_object_type_id" DefaultValue="-1" />
      </InsertParameters>
    </asp:SqlDataSource>
    <!--Data source for criticallity dropdown-->
    <!--Change Project ID to select criticality from right Binder: id 3 = GNRM-->
    <asp:SqlDataSource ID="SqlDataSource_Criticality" 
                       runat="server" 
                       ConnectionString="<%$ ConnectionStrings:OCConnectionString_utcriticality %>" 
                       SelectCommand="SELECT project_id, ut_value, criticality_id FROM utcriticality WHERE (project_id = 3)" 
                       onselecting="SqlDataSource1_Selecting">
    </asp:SqlDataSource>
    <!--End data source for criticallity dropdown-->
  </div>
</form>
</body>
</html>

'我们的函数generatePassword接受一个参数'passwordLength'
'passwordLength显然将决定密码长度。
'将APLUMERIC字符集分配给变量sDefaultChars
函数生成器密码(密码长度)
'声明变量
黯淡
暗色计数器
模糊sMyPassword
Dim iPickedChar
Dim IdeFaultCharacter长度
单字长度
'初始化变量
sDefaultChars=“abcdefghijklmnopqrstuvxyzABCDEFGHIJKLMNOPQRSTUVXYZ0123456789”
iPasswordLength=密码长度
iDefaultCharactersLength=Len(sDefaultChars)
Randomize()'初始化随机数生成器
'密码的字符数循环为
对于iCounter=1到iPasswordLength
'下一步从1到字符集长度中选择一个数字
iPickedChar=Int((iDefaultCharactersLength*Rnd)+1)
'接下来使用随机数iPickedChar从字符集中拾取一个字符
'和中间功能
sMyPassword=sMyPassword&Mid(sDefaultChars,iPickedChar,1)
下一个
generatePassword=sMyPassword
端函数
子表单视图1\u插入的项目(ByVal sender作为对象,ByVal e作为FormViewInsertedEventArgs)
Response.Redirect(“ThankYou.asp”)
端接头
受保护的子窗体View1\u PageIndexChanging(发件人作为对象,e作为System.Web.UI.WebControl.FormViewPageEventArgs)
端接头
受保护的子SqlDataSource1_选择(发件人作为对象,e作为System.Web.UI.WebControl.SqlDataSourceSelectingEventArgs)
端接头
.style1
{
宽度:100%;
}
关键性标识:

案例编号: **
说明:
外部电子邮件地址:
**
插入代码在哪里?顺便说一下,我建议学习如何使用代码隐藏。不是100%确定,但类似的方法可能会奏效(如果我正确阅读了您的评论):
Text=''
I get:Description:解析服务此请求所需的资源时出错。请查看以下特定的解析错误详细信息,并适当修改源文件。解析器错误消息:绑定调用的格式不正确。请参阅文档以了解正确的参数to绑定。源错误:第96行:第97行:第98行:第100行: