惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Recent Announcements
Recent Announcements
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Application and Cybersecurity Blog
Application and Cybersecurity Blog
N
News | PayPal Newsroom
P
Proofpoint News Feed
L
Lohrmann on Cybersecurity
S
Security @ Cisco Blogs
K
Kaspersky official blog
A
Arctic Wolf
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Project Zero
Project Zero
L
LINUX DO - 最新话题
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
The Last Watchdog
The Last Watchdog
T
The Exploit Database - CXSecurity.com
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Security Archives - TechRepublic
Security Archives - TechRepublic
V
V2EX
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
H
Hackread – Cybersecurity News, Data Breaches, AI and More
爱范儿
爱范儿
F
Full Disclosure
I
Intezer
Schneier on Security
Schneier on Security
AWS News Blog
AWS News Blog
C
Cybersecurity and Infrastructure Security Agency CISA
博客园 - 聂微东
M
MIT News - Artificial intelligence
P
Privacy & Cybersecurity Law Blog
Attack and Defense Labs
Attack and Defense Labs
量子位
Google DeepMind News
Google DeepMind News
T
Threat Research - Cisco Blogs
Last Week in AI
Last Week in AI
Google Online Security Blog
Google Online Security Blog
博客园 - 三生石上(FineUI控件)
WordPress大学
WordPress大学
Microsoft Security Blog
Microsoft Security Blog
Scott Helme
Scott Helme
C
Check Point Blog
N
Netflix TechBlog - Medium
博客园 - Franky
SecWiki News
SecWiki News
Know Your Adversary
Know Your Adversary
Engineering at Meta
Engineering at Meta
F
Fortinet All Blogs
Blog — PlanetScale
Blog — PlanetScale
S
Securelist

博客园 - javaca88

SQL高级语法汇总 textaera maxlength - javaca88 - 博客园 聚焦索引与非聚焦索引及其查询效率 zhuan - javaca88 - 博客园 博文阅读密码验证 - 博客园 FormView1.ChangeMode 最经典的实现字符数控制的方案哦!(完善版)(转) JavaScript实际应用:父子页面交互 如何取得treeview的节点的checkbox的value值 - javaca88 - 博客园 DetailsView1 动态添加自动列 - javaca88 - 博客园 要用到的代码2 - javaca88 - 博客园 技术网站收录 grid view控件中经常会遇到选择行的问题,怎么才能获得当前行呢 step by step 7 转:C#.Net的常见面试试题 zuo ye 缓冲池 Assembly.Load 获取硬盘序列号 split 正确用法 在SQLSERVER里写了一个Split函数
FormView1 动态传参数
javaca88 · 2006-10-26 · via 博客园 - javaca88

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class addSer : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Session["userId"] == null)
            {
                Response.Write("<script>alert('你还没有登陆');window.target='main';window.location.href='logic.aspx'</script>");
            }
            else
            {
               // DetailsView1.DefaultMode = DetailsViewMode.Insert;
            }

        }
    }

    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        DropDownList dr = (DropDownList)FormView1.FindControl("DropDownList1");
        SqlDataSource1.InsertParameters[1].DefaultValue = dr.SelectedValue;
    }

    protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
    {
        DropDownList dr = (DropDownList)FormView1.FindControl("DropDownList2");
        SqlDataSource1.InsertParameters[7].DefaultValue = dr.SelectedValue;
    }

    protected void DropDownList3_SelectedIndexChanged(object sender, EventArgs e)
    {
        DropDownList dr = (DropDownList)FormView1.FindControl("DropDownList3");
        SqlDataSource1.InsertParameters[8].DefaultValue = dr.SelectedValue;
    }

    protected void DropDownList4_SelectedIndexChanged(object sender, EventArgs e)
    {
        DropDownList dr = (DropDownList)FormView1.FindControl("DropDownList4");
        SqlDataSource1.InsertParameters[10].DefaultValue = dr.SelectedValue;
    }


    protected void FormView1_ItemInserting(object sender, FormViewInsertEventArgs e)
    {
        if (SqlDataSource1.InsertParameters[1].DefaultValue == null)
        {
            DropDownList dr = (DropDownList)FormView1.FindControl("DropDownList1");
            SqlDataSource1.InsertParameters[1].DefaultValue = dr.Text;
        }

        if (SqlDataSource1.InsertParameters[7].DefaultValue == null)
        {
             DropDownList dr = (DropDownList)FormView1.FindControl("DropDownList2");
             SqlDataSource1.InsertParameters[7].DefaultValue = dr.Text;
        }

        if (SqlDataSource1.InsertParameters[8].DefaultValue == null)
        {
            DropDownList dr = (DropDownList)FormView1.FindControl("DropDownList3");
            SqlDataSource1.InsertParameters[8].DefaultValue = dr.Text;
        }

        if (SqlDataSource1.InsertParameters[10].DefaultValue == null)
        {
            DropDownList dr = (DropDownList)FormView1.FindControl("DropDownList4");
            SqlDataSource1.InsertParameters[10].DefaultValue = dr.Text;
        }
    }
    protected void FormView1_ItemInserted(object sender, FormViewInsertedEventArgs e)
    {
        Response.Write("<script>alert('插入成功,请继续添加');</script>");
    }
}

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="addSer.aspx.cs" Inherits="addSer"  %>

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

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>无标题页</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        &nbsp;&nbsp;&nbsp;
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:gpCustomerConnectionString %>"
            DeleteCommand="DELETE FROM [mendRecordTable] WHERE [mendFileId] = @mendFileId"
            InsertCommand="INSERT INTO [mendRecordTable] ([creatTime], [creatEmployId], [proId], [proCode], [customerId], [stateBeforeMend], [mendRecord], [mendEmployId], [quchEmployId], [outTime], [outDoEmployId], [receiveCom], [receiveMen], [receiveAdd], [receiveTel], [outDemo]) VALUES (@creatTime, @creatEmployId, @proId, @proCode, @customerId, @stateBeforeMend, @mendRecord, @mendEmployId, @quchEmployId, @outTime, @outDoEmployId, @receiveCom, @receiveMen, @receiveAdd, @receiveTel, @outDemo)"
            SelectCommand="SELECT * FROM [mendRecordTable]" UpdateCommand="UPDATE [mendRecordTable] SET [creatTime] = @creatTime, [creatEmployId] = @creatEmployId, [proId] = @proId, [proCode] = @proCode, [customerId] = @customerId, [stateBeforeMend] = @stateBeforeMend, [mendRecord] = @mendRecord, [mendEmployId] = @mendEmployId, [quchEmployId] = @quchEmployId, [outTime] = @outTime, [outDoEmployId] = @outDoEmployId, [receiveCom] = @receiveCom, [receiveMen] = @receiveMen, [receiveAdd] = @receiveAdd, [receiveTel] = @receiveTel, [outDemo] = @outDemo WHERE [mendFileId] = @mendFileId">
            <DeleteParameters>
                <asp:Parameter Name="mendFileId" Type="Int32" />
            </DeleteParameters>
            <UpdateParameters>
                <asp:Parameter Name="creatTime" Type="DateTime" />
                <asp:Parameter Name="creatEmployId" Type="String" />
                <asp:Parameter Name="proId" Type="String" />
                <asp:Parameter Name="proCode" Type="String" />
                <asp:Parameter Name="customerId" Type="String" />
                <asp:Parameter Name="stateBeforeMend" Type="String" />
                <asp:Parameter Name="mendRecord" Type="String" />
                <asp:Parameter Name="mendEmployId" Type="String" />
                <asp:Parameter Name="quchEmployId" Type="String" />
                <asp:Parameter Name="outTime" Type="DateTime" />
                <asp:Parameter Name="outDoEmployId" Type="String" />
                <asp:Parameter Name="receiveCom" Type="String" />
                <asp:Parameter Name="receiveMen" Type="String" />
                <asp:Parameter Name="receiveAdd" Type="String" />
                <asp:Parameter Name="receiveTel" Type="String" />
                <asp:Parameter Name="outDemo" Type="String" />
                <asp:Parameter Name="mendFileId" Type="Int32" />
            </UpdateParameters>
            <InsertParameters>
                <asp:Parameter Name="creatTime" Type="DateTime" />
                <asp:Parameter Name="creatEmployId" Type="String" />
                <asp:Parameter Name="proId" Type="String" />
                <asp:Parameter Name="proCode" Type="String" />
                <asp:Parameter Name="customerId" Type="String" />
                <asp:Parameter Name="stateBeforeMend" Type="String" />
                <asp:Parameter Name="mendRecord" Type="String" />
                <asp:Parameter Name="mendEmployId" Type="String" />
                <asp:Parameter Name="quchEmployId" Type="String" />
                <asp:Parameter Name="outTime" Type="DateTime" />
                <asp:Parameter Name="outDoEmployId" Type="String" />
                <asp:Parameter Name="receiveCom" Type="String" />
                <asp:Parameter Name="receiveMen" Type="String" />
                <asp:Parameter Name="receiveAdd" Type="String" />
                <asp:Parameter Name="receiveTel" Type="String" />
                <asp:Parameter Name="outDemo" Type="String" />
            </InsertParameters>
        </asp:SqlDataSource>
    </div>
        <asp:FormView ID="FormView1" runat="server" DefaultMode="Insert" DataKeyNames="mendFileId" DataSourceID="SqlDataSource1" OnItemInserting="FormView1_ItemInserting" Width="360px" OnItemInserted="FormView1_ItemInserted">
            <EditItemTemplate>
        
                mendFileId:
                <asp:TextBox ID="mendFileIdTextBox1" runat="server" Text='<%# Eval("mendFileId") %>'>
                </asp:TextBox><br />
                creatTime:
                <asp:TextBox ID="creatTimeTextBox" runat="server" Text='<%# Bind("creatTime") %>'>
                </asp:TextBox><br />
                creatEmployId:
                <asp:TextBox ID="creatEmployIdTextBox" runat="server" Text='<%# Bind("creatEmployId") %>'>
                </asp:TextBox><br />
                proId:
                <asp:TextBox ID="proIdTextBox" runat="server" Text='<%# Bind("proId") %>'>
                </asp:TextBox><br />
                proCode:
                <asp:TextBox ID="proCodeTextBox" runat="server" Text='<%# Bind("proCode") %>'>
                </asp:TextBox><br />
                customerId:
                <asp:TextBox ID="customerIdTextBox" runat="server" Text='<%# Bind("customerId") %>'>
                </asp:TextBox><br />
                stateBeforeMend:
                <asp:TextBox ID="stateBeforeMendTextBox" runat="server" Text='<%# Bind("stateBeforeMend") %>'>
                </asp:TextBox><br />
                mendRecord:
                <asp:TextBox ID="mendRecordTextBox" runat="server" Text='<%# Bind("mendRecord") %>'>
                </asp:TextBox><br />
                mendEmployId:
                <asp:TextBox ID="mendEmployIdTextBox" runat="server" Text='<%# Bind("mendEmployId") %>'>
                </asp:TextBox><br />
                quchEmployId:
                <asp:TextBox ID="quchEmployIdTextBox" runat="server" Text='<%# Bind("quchEmployId") %>'>
                </asp:TextBox><br />
                outTime:
                <asp:TextBox ID="outTimeTextBox" runat="server" Text='<%# Bind("outTime") %>'>
                </asp:TextBox><br />
                outDoEmployId:
                <asp:TextBox ID="outDoEmployIdTextBox" runat="server" Text='<%# Bind("outDoEmployId") %>'>
                </asp:TextBox><br />
                receiveCom:
                <asp:TextBox ID="receiveComTextBox" runat="server" Text='<%# Bind("receiveCom") %>'>
                </asp:TextBox><br />
                receiveMen:
                <asp:TextBox ID="receiveMenTextBox" runat="server" Text='<%# Bind("receiveMen") %>'>
                </asp:TextBox><br />
                receiveAdd:
                <asp:TextBox ID="receiveAddTextBox" runat="server" Text='<%# Bind("receiveAdd") %>'>
                </asp:TextBox><br />
                receiveTel:
                <asp:TextBox ID="receiveTelTextBox" runat="server" Text='<%# Bind("receiveTel") %>'>
                </asp:TextBox><br />
                outDemo:
                <asp:TextBox ID="outDemoTextBox" runat="server" Text='<%# Bind("outDemo") %>'>
                </asp:TextBox><br />
                <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update"
                    Text="更新">
                </asp:LinkButton>
                <asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
                    Text="取消">
                </asp:LinkButton>
            </EditItemTemplate>
            <InsertItemTemplate>
            <table>
              <tr><td>  建档日期:</td><td>
                <asp:TextBox ID="creatTimeTextBox" runat="server" Text='<%# Bind("creatTime") %>'>
                </asp:TextBox></td></tr>
               <tr><td>  建档人工号:</td><td>
                  <asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="SqlDataSource2" DataTextField="Name" DataValueField="employId" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged"  >
                   </asp:DropDownList></td></tr>
               <tr><td>  产品ID:</td><td>
                <asp:TextBox ID="proIdTextBox" runat="server" Text='<%# Bind("proId") %>'>
                </asp:TextBox></td></tr>
               <tr><td> 产品编号:</td><td>
                <asp:TextBox ID="proCodeTextBox" runat="server" Text='<%# Bind("proCode") %>'>
                </asp:TextBox></td></tr>
               <tr><td>  客户ID:</td><td>
                <asp:TextBox ID="customerIdTextBox" runat="server" Text='<%# Bind("customerId") %>'>
                </asp:TextBox></td></tr>
               <tr><td>   维修前情况:</td><td>
                <asp:TextBox ID="stateBeforeMendTextBox" runat="server" Text='<%# Bind("stateBeforeMend") %>' TextMode="MultiLine">
                </asp:TextBox></td></tr>
                <tr><td> 维修记录:</td><td>
                <asp:TextBox ID="mendRecordTextBox" runat="server" Text='<%# Bind("mendRecord") %>' TextMode="MultiLine">
                </asp:TextBox></td></tr>
               <tr><td>  维修人工号:</td><td>
               <asp:DropDownList ID="DropDownList2" runat="server" DataSourceID="SqlDataSource2" DataTextField="Name" DataValueField="employId" OnSelectedIndexChanged="DropDownList2_SelectedIndexChanged"  >
                   </asp:DropDownList></td></tr>
                <tr><td>质检人工号:</td><td><asp:DropDownList ID="DropDownList3" runat="server" DataSourceID="SqlDataSource2" DataTextField="Name" DataValueField="employId" OnSelectedIndexChanged="DropDownList3_SelectedIndexChanged"  >
                   </asp:DropDownList>
              </td></tr>
                <tr><td>发货日期:</td><td>
                <asp:TextBox ID="outTimeTextBox" runat="server" Text='<%# Bind("outTime") %>'>
                </asp:TextBox></td></tr>
               <tr><td> 发货经办人工号:</td><td><asp:DropDownList ID="DropDownList4" runat="server" DataSourceID="SqlDataSource2" DataTextField="Name" DataValueField="employId" OnSelectedIndexChanged="DropDownList4_SelectedIndexChanged"  >
                   </asp:DropDownList>
                </td></tr>
               <tr><td>  收货单位 :</td><td>
                <asp:TextBox ID="receiveComTextBox" runat="server" Text='<%# Bind("receiveCom") %>'>
                </asp:TextBox></td></tr>
                <tr><td>收货人:</td><td>
                <asp:TextBox ID="receiveMenTextBox" runat="server" Text='<%# Bind("receiveMen") %>'>
                </asp:TextBox></td></tr>
               <tr><td>  收货人地址:</td><td>
                <asp:TextBox ID="receiveAddTextBox" runat="server" Text='<%# Bind("receiveAdd") %>'>
                </asp:TextBox></td></tr>
                <tr><td>收货人电话:</td><td>
                <asp:TextBox ID="receiveTelTextBox" runat="server" Text='<%# Bind("receiveTel") %>'>
                </asp:TextBox></td></tr>
                <tr><td>发货备注:</td><td>
                <asp:TextBox ID="outDemoTextBox" runat="server" Text='<%# Bind("outDemo") %>' TextMode="MultiLine">
                </asp:TextBox></td></tr>
                <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" CommandName="Insert"
                    Text="插入">
                </asp:LinkButton><asp:LinkButton ID="InsertCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
                    Text="取消">
                </asp:LinkButton></table>
            </InsertItemTemplate>
            <ItemTemplate>
                mendFileId:
                <asp:TextBox ID="mendFileIdTextBox" runat="server" Text='<%# Eval("mendFileId") %>'>
                </asp:TextBox><br />
                creatTime:
                <asp:TextBox ID="creatTimeTextBox" runat="server" Text='<%# Bind("creatTime") %>'></asp:TextBox><br />
                creatEmployId:
                <asp:TextBox ID="creatEmployIdTextBox" runat="server" Text='<%# Bind("creatEmployId") %>'>
                </asp:TextBox><br />
                proId:
                <asp:TextBox ID="proIdTextBox" runat="server" Text='<%# Bind("proId") %>'></asp:TextBox><br />
                proCode:
                <asp:TextBox ID="proCodeTextBox" runat="server" Text='<%# Bind("proCode") %>'></asp:TextBox><br />
                customerId:
                <asp:TextBox ID="customerIdTextBox" runat="server" Text='<%# Bind("customerId") %>'>
                </asp:TextBox><br />
                stateBeforeMend:
                <asp:TextBox ID="stateBeforeMendTextBox" runat="server" Text='<%# Bind("stateBeforeMend") %>'>
                </asp:TextBox><br />
                mendRecord:
                <asp:TextBox ID="mendRecordTextBox" runat="server" Text='<%# Bind("mendRecord") %>'>
                </asp:TextBox><br />
                mendEmployId:
                <asp:TextBox ID="mendEmployIdTextBox" runat="server" Text='<%# Bind("mendEmployId") %>'>
                </asp:TextBox><br />
                quchEmployId:
                <asp:TextBox ID="quchEmployIdTextBox" runat="server" Text='<%# Bind("quchEmployId") %>'>
                </asp:TextBox><br />
                outTime:
                <asp:TextBox ID="outTimeTextBox" runat="server" Text='<%# Bind("outTime") %>'></asp:TextBox><br />
                outDoEmployId:
                <asp:TextBox ID="outDoEmployIdTextBox" runat="server" Text='<%# Bind("outDoEmployId") %>'>
                </asp:TextBox><br />
                receiveCom:
                <asp:TextBox ID="receiveComTextBox" runat="server" Text='<%# Bind("receiveCom") %>'>
                </asp:TextBox><br />
                receiveMen:
                <asp:TextBox ID="receiveMenTextBox" runat="server" Text='<%# Bind("receiveMen") %>'>
                </asp:TextBox><br />
                receiveAdd:
                <asp:TextBox ID="receiveAddTextBox" runat="server" Text='<%# Bind("receiveAdd") %>'>
                </asp:TextBox><br />
                receiveTel:
                <asp:TextBox ID="receiveTelTextBox" runat="server" Text='<%# Bind("receiveTel") %>'>
                </asp:TextBox><br />
                outDemo:
                <asp:TextBox ID="outDemoTextBox" runat="server" Text='<%# Bind("outDemo") %>'></asp:TextBox><br />
                <asp:LinkButton ID="EditButton" runat="server" CausesValidation="False" CommandName="Edit"
                    Text="编辑">
                </asp:LinkButton>
                <asp:LinkButton ID="DeleteButton" runat="server" CausesValidation="False" CommandName="Delete"
                    Text="删除">
                </asp:LinkButton>
                <asp:LinkButton ID="NewButton" runat="server" CausesValidation="False" CommandName="New"
                    Text="新建">
                </asp:LinkButton>
            </ItemTemplate>
        </asp:FormView>
        <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:gpCustomerConnectionString %>"
            SelectCommand="SELECT * FROM [employTable]"></asp:SqlDataSource>
        <br />
    </form>
</body>
</html>