使用SqlDataSource进行数据绑定后的事件

时间:2015-06-15 08:59:52

标签: asp.net

我有一个要搜索的文本框和我页面中的一个FormView:

<div runat="server" id="adminArea">
    <table>
        <tr>
            <td>
                <asp:Label ID="Label4" runat="server" Text="Enter a Member ID :"></asp:Label></td>
            <td><br />
                <asp:TextBox ID="TextBox5" runat="server" TextMode="Number"></asp:TextBox><br />
                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" ValidationGroup="vgSearch" ForeColor="Red" ControlToValidate="TextBox5" runat="server" ErrorMessage="Enter a valid Member Id"></asp:RequiredFieldValidator>
            </td>
            <td>
                <asp:Button ID="Button1" OnClick="Button1_Click" CssClass="btn btn-primary" runat="server" Text="Search" ValidationGroup="vgSearch" /></td>
        </tr>
    </table>
</div>

<asp:FormView ID="FormView1" DefaultMode="Edit" Width="100%" runat="server" DataSourceID="profileInformationDataSource" DataKeyNames="id" >
    <EditItemTemplate>
           <table align="center" cellpadding="5" cellspacing="5" class="auto-style1" style="margin-top:20px;">
               <tr>
                    <td colspan="3"><b><%# Eval("name") %></b>'s Profile</td>
               </tr>
               /**
               ** Many fields are here to bind
               **/
    </EditItemTemplate>
</asp:FormView>

要绑定上面的表单字段,我使用的是SqlDataSource:

 <asp:SqlDataSource ID="profileInformationDataSource" runat="server" ConnectionString='<%$ ConnectionStrings:DefaultConnection %>' SelectCommand="SELECT Top 1 mem.name,mem.img_src,mem.id, CONVERT(VARCHAR(10), mem.dob, 111) as dob,mem.sex,mem.member_cert_id,mem.address,mem.Country , mem.state,mem.city,mem.zip,mem.phone,mem.mobile,mem.email_id,mem.bank_acc_no,mem.bank_pan_no,mem.account_holder_name,mem.bank_name,mem.bank_code,mem.bank_address,mem.bank_zip,mem.bank_location,mem.bank_country,mem.bank_branch FROM Members as mem where mem.id = @memberId order by mem.id desc"
 UpdateCommand="UPDATE Members SET name = @name, dob = @dob , member_cert_id = @member_cert_id , address = @address , Country = @Country, state = @state , zip = @zip, mobile= @mobile , phone= @phone, email_id = @email_id, bank_pan_no = @bank_pan_no, bank_acc_no = @bank_acc_no, account_holder_name = @account_holder_name, bank_name= @bank_name, bank_code = @bank_code, bank_address = @bank_address, bank_zip =@bank_zip, bank_location = @bank_location Where id= @id " >
        <SelectParameters>
                 <asp:ControlParameter ControlID="TextBox5" DefaultValue="0" Name="memberId" PropertyName="Text" />
        </SelectParameters>

    <UpdateParameters>
        <asp:Parameter Name="name" Type="String" />
        <asp:Parameter Name="dob" Type="String" />
        <asp:Parameter Name="member_cert_id" Type="String" />
        <asp:Parameter Name="address" Type="String" />
        <asp:Parameter Name="Country" Type="String" />
        <asp:Parameter Name="state" Type="String" />
        <asp:Parameter Name="zip" Type="String" />
        <asp:Parameter Name="mobile" Type="String" />
        <asp:Parameter Name="phone" Type="String" />
        <asp:Parameter Name="email_id" Type="String" />
        <asp:Parameter Name="bank_pan_no" Type="String" />
        <asp:Parameter Name="bank_acc_no" Type="String" />
        <asp:Parameter Name="account_holder_name" Type="String" />
        <asp:Parameter Name="bank_name" Type="String" />
        <asp:Parameter Name="bank_code" Type="String" />
        <asp:Parameter Name="bank_address" Type="String" />
        <asp:Parameter Name="bank_zip" Type="String" />
        <asp:Parameter Name="bank_location" Type="String" />
        <asp:Parameter Name="id" />
    </UpdateParameters>

</asp:SqlDataSource>

每当我点击搜索按钮时,字段都由SqlDataSource填充。现在我的问题是,在FormView中,我有用于国家,州和城市下拉列表的UpdatePanels。所以我想从我的后端代码中加载它们。

所以我想要一个在填充数据后启动的事件。

0 个答案:

没有答案