Thanks. Can I have the clear steps (shown with few screenshots) to do this below?
Hi,
You can do the following things:
1) Drag and drop the SqlDataSource onto the WebForm.
2) Click the DataSource control and choose "Configuration Settings……“。
3)In the pop-up Dialog, please first create the connection to the database and table, and then click some columns you wanna show, and then click "Advanced……".
The project is connecting to SS 2012 DB on the server. I already have sent the screenshot to you.
Hi,
I've received your image, and I find that you are wrong. I mean you should drag and drop a SqlDataSource control from the toolbox instead of creating another new file.
I've received your image, and I find that you are wrong. I mean you should drag and drop a SqlDataSource control from the toolbox instead of creating another new file.
But this link
http://www.devmanuals.com/tutorials/ms/aspdotnet/sqldatasource.html
never mentions the way to choose anything from Toolbar. Do you choose a Formview? Can I have the full details step by step?
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: Ensure "Insert" button is fine
Jan 27, 2013 01:20 AM|LINK
Click the SqlDataSource control and then choose "Configure Schema", and then you will go inside the pop-up wizard window.
And then please choose "Advanced……" and let it generate CRUD (Insert, Delete, Update methods for your table with a primary key).
For more see:
http://msdn.microsoft.com/en-us/library/aa992071(v=VS.90).aspx
wmec
Contributor
6556 Points
3324 Posts
Re: Ensure "Insert" button is fine
Jan 27, 2013 08:23 AM|LINK
Thanks. Can I have the clear steps (shown with few screenshots) to do this below?
Click the SqlDataSource control and then choose "Configure Schema", and then you will go inside the pop-up wizard window.
HuaMin Chen
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: Ensure "Insert" button is fine
Jan 27, 2013 08:50 AM|LINK
Hi,
You can do the following things:
1) Drag and drop the SqlDataSource onto the WebForm.
2) Click the DataSource control and choose "Configuration Settings……“。
3)In the pop-up Dialog, please first create the connection to the database and table, and then click some columns you wanna show, and then click "Advanced……".
For picutures,you can see this:
http://www.devmanuals.com/tutorials/ms/aspdotnet/sqldatasource.html
wmec
Contributor
6556 Points
3324 Posts
Re: Ensure "Insert" button is fine
Jan 28, 2013 02:16 AM|LINK
Many thanks. Which should I choose below? I don't know why it is a mdf file in it.
http://dl.dropbox.com/u/40211031/t318.png
HuaMin Chen
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: Ensure "Insert" button is fine
Jan 28, 2013 07:35 AM|LINK
Have you installed SQL Express?
And I cannot see your image, please attach your image on SkyDrive and then nest your image onto here.
Or just send your image to my email.
wmec
Contributor
6556 Points
3324 Posts
Re: Ensure "Insert" button is fine
Jan 28, 2013 08:22 AM|LINK
Hi,
The project is connecting to SS 2012 DB on the server. I already have sent the screenshot to you.
HuaMin Chen
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: Ensure "Insert" button is fine
Jan 28, 2013 08:24 AM|LINK
Hi,
I've received your image, and I find that you are wrong. I mean you should drag and drop a SqlDataSource control from the toolbox instead of creating another new file.
wmec
Contributor
6556 Points
3324 Posts
Re: Ensure "Insert" button is fine
Jan 28, 2013 08:34 AM|LINK
But this link
http://www.devmanuals.com/tutorials/ms/aspdotnet/sqldatasource.html
never mentions the way to choose anything from Toolbar. Do you choose a Formview? Can I have the full details step by step?
HuaMin Chen
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: Ensure "Insert" button is fine
Jan 28, 2013 10:25 AM|LINK
Choose a FormView
Choose a SqlDataSource
Set DataSourceId of the SqlDataSource to FormView
Configure the SqlDataSource as my link;)
wmec
Contributor
6556 Points
3324 Posts
Re: Ensure "Insert" button is fine
Jan 29, 2013 01:59 AM|LINK
Thanks Decker. I followed the stesp to create the formview. But when running the project, I do not see this formview. Why?
<asp:FormView ID="FormView1" runat="server" DataKeyNames="rec_id"
DataSourceID="SqlDataSource1">
<EditItemTemplate>
rec_id:
<asp:Label ID="rec_idLabel1" runat="server" Text='<%# Eval("rec_id") %>' />
<br />
user_id:
<asp:TextBox ID="user_idTextBox" runat="server" Text='<%# Bind("user_id") %>' />
<br />
int_desc:
<asp:TextBox ID="int_descTextBox" runat="server"
Text='<%# Bind("int_desc") %>' />
<br />
change_date:
<asp:TextBox ID="change_dateTextBox" runat="server"
Text='<%# Bind("change_date") %>' />
<br />
<asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True"
CommandName="Update" Text="Update" />
<asp:LinkButton ID="UpdateCancelButton" runat="server"
CausesValidation="False" CommandName="Cancel" Text="Cancel" />
</EditItemTemplate>
<InsertItemTemplate>
user_id:
<asp:TextBox ID="user_idTextBox" runat="server" Text='<%# Bind("user_id") %>' />
<br />
int_desc:
<asp:TextBox ID="int_descTextBox" runat="server"
Text='<%# Bind("int_desc") %>' />
<br />
change_date:
<asp:TextBox ID="change_dateTextBox" runat="server"
Text='<%# Bind("change_date") %>' />
<br />
<asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True"
CommandName="Insert" Text="Insert" />
<asp:LinkButton ID="InsertCancelButton" runat="server"
CausesValidation="False" CommandName="Cancel" Text="Cancel" />
</InsertItemTemplate>
<ItemTemplate>
rec_id:
<asp:Label ID="rec_idLabel" runat="server" Text='<%# Eval("rec_id") %>' />
<br />
user_id:
<asp:Label ID="user_idLabel" runat="server" Text='<%# Bind("user_id") %>' />
<br />
int_desc:
<asp:Label ID="int_descLabel" runat="server" Text='<%# Bind("int_desc") %>' />
<br />
change_date:
<asp:Label ID="change_dateLabel" runat="server"
Text='<%# Bind("change_date") %>' />
<br />
<asp:LinkButton ID="EditButton" runat="server" CausesValidation="False"
CommandName="Edit" Text="Edit" />
<asp:LinkButton ID="DeleteButton" runat="server" CausesValidation="False"
CommandName="Delete" Text="Delete" />
<asp:LinkButton ID="NewButton" runat="server" CausesValidation="False"
CommandName="New" Text="New" />
</ItemTemplate>
</asp:FormView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:Mssqlconn2 %>"
DeleteCommand="DELETE FROM [tab3] WHERE [rec_id] = @rec_id"
InsertCommand="INSERT INTO [tab3] ([user_id], [int_desc], [change_date]) VALUES (@user_id, @int_desc, @change_date)"
SelectCommand="SELECT * FROM [tab3]"
UpdateCommand="UPDATE [tab3] SET [user_id] = @user_id, [int_desc] = @int_desc, [change_date] = @change_date WHERE [rec_id] = @rec_id">
<DeleteParameters>
<asp:Parameter Name="rec_id" Type="Int32" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="user_id" Type="Int32" />
<asp:Parameter Name="int_desc" Type="String" />
<asp:Parameter Name="change_date" Type="DateTime" />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name="user_id" Type="Int32" />
<asp:Parameter Name="int_desc" Type="String" />
<asp:Parameter Name="change_date" Type="DateTime" />
<asp:Parameter Name="rec_id" Type="Int32" />
</UpdateParameters>
</asp:SqlDataSource>
...
HuaMin Chen