Home All Groups Group Topic Archive Search About

How bind textbox to parameter for insert (2005)

Author
13 Jan 2006 7:51 PM
VB Programmer
Using ASP.NET 2.0.  I have a custom form to create a new user.

I've created the datasource as the following:
<asp:SqlDataSource ID="dsrcUsers" runat="server" ConnectionString="<%$
ConnectionStrings:MyMainDatabase %>"
        SelectCommand="SELECT * FROM [MyUsers]" InsertCommand="INSERT INTO
[MyUsers] ([UserId], [FirstName], [LastName], [MyPhone]) VALUES (@UserId,
@FirstName, @LastName, @MyPhone)">
        <InsertParameters>
            <asp:Parameter Name="UserId" Type="Object" />
            <asp:Parameter Name="FirstName" Type="String" />
            <asp:Parameter Name="LastName" Type="String" />
            <asp:Parameter Name="MyPhone" Type="String" />
        </InsertParameters>
        </asp:SqlDataSource>

Question:  Is there an easy way to make the .insert command AUTOMATICALLY
pull from the corresponding textboxes?  Or do I have to create a new
parameter object in code and set the .text property to be the param values?

AddThis Social Bookmark Button