ASP SQL WebForm-搜索,插入,编辑操作 [英] ASP SQL WebForm - Search, Insert, Edit Operations

查看:82
本文介绍了ASP SQL WebForm-搜索,插入,编辑操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要创建一个简单的Web窗体应用程序,使用户可以搜索字段,插入新行并编辑现有行.我是ASP和SQL的新手.我正在使用Visual Studio 2010和SQL Server 2005,并且正在发布到IIS公司Web服务器.

我已经用谷歌搜索了两个星期,但似乎无法获得任何有效的方法.我尝试了gridview,listview,数据转发器.

基本上,我必须执行以下操作:

-在SQL数据库中的多个字段中搜索并向用户显示结果
-分页返回的数据,这样我一次只能在一页上有10条记录
-编辑数据库中的现有记录,并防止5个字段中的1个被编辑
-将新记录插入数据库并进行测试,以确保在添加新记录之前填充了1个必填字段

有人可以帮我弄清楚该怎么做吗?

I need to create a simple web form application that lets a user Search fields, Insert a new row, and edit an existing row. I''m new to ASP and SQL. I''m using Visual Studio 2010 and SQL Server 2005 and I''m publishing out to an IIS corporate web server.

I have google''d this for two weeks and I just can''t seem to get something that works. I''ve tried gridview, listview, data repeater.

Basically, I have to do the following:

- Search on more than field in the SQL database and display the results to the user
- Page the data that is returned so that I only have 10 records on a page at one time
- Edit an existing record in the database and prevent 1 of the 5 fields from being edited
- Insert a new record into the database and test to make sure the 1 required field is populated before adding the new record

Can anyone help me figure out how to do this?

推荐答案

1)在SQL数据库中搜索多个字段并将结果显示给用户

有许多详细资料存取的可用资源.您尝试了什么?

2)分页返回的数据,这样我一次只能在一页上有10条记录

是的,gridview可以很好地工作.您尝试了什么?

3)编辑数据库中的现有记录,并防止5个字段中的1个被编辑
好的,只是不要更新该字段.您尝试了什么?


4)将新记录插入数据库并进行测试,以确保在添加新记录之前填充了1个必填字段

表单验证?数据实体验证?同样,有很多资源可以解决此问题.您尝试了什么?


我发现您花了两个星期的Goolge-ing时间,却没有发现任何有用的东西,这令人难以置信.每本基本的ASP.NET书籍都有关于数据访问的至少一章.
1) Search on more than field in the SQL database and display the results to the user

There are many, many, many resources available that detail data access. What have you tried?

2) Page the data that is returned so that I only have 10 records on a page at one time

Yes, a gridview will work nicely fr this. What have you tried?

3) Edit an existing record in the database and prevent 1 of the 5 fields from being edited
OK, just don''t update that field. What have you tried?


4) Insert a new record into the database and test to make sure the 1 required field is populated before adding the new record

Form validation? Data Entity validation? Again, there are many, many, resources that cover this. What have you tried?


I find it incredulous that you have spent two weeks Goolge-ing and have not found anything useful. Every basic ASP.NET book has at lease one chapter on data access.


我认为我对Google不太满意的原因是我不知道什么我在找.我的搜索字词实际上是通用的,我试图弄清楚要搜索的内容,或者在那里找到一个简单的示例程序,可以用来查看并分解如何做.
1)在字段上搜索...在此字段上我还没有尝试过任何操作.我一直在试图找出方法.我发现了可以显示如何进行SQL查询的内容,但我不知道如何执行它然后更新页面.

2)我最初尝试了一个Repeater,然后尝试了一个GridView,最后终于有了一个ListView. ListView是我发现唯一支持分页的列表.我喜欢ListView和Repeater简化数据布局的方式,因为我大约有15列,并将它们全部放在网格中的一行中使其非常宽.

3&4)我什至不知道如何开始使用Repeater或GridView进行编辑或插入. ListView支持EditItem模板和UpdateItem模板,因此这就是我一直在使用的东西.如果他们不应该编辑这些字段,那么我将不知道该如何显示该字段并将其在编辑"中显示为只读.如果一个字段为空,我无法弄清楚如何阻止它插入.
I think the reason that I haven''t had much luck with google is that I don''t know what I''m looking for. My search terms are really generic and I''m trying to figure out what to search for or find a simple sample program out there I can use to look at and break apart how to do it.

1) Searching on fields... I haven''t tried anything on this one yet. I''ve been trying to figure out how. I found things that show how to make a SQL Query, but I don''t know how to execute it and then update the page.

2) I tried a Repeater initially, then a GridView and then finally I have a ListView now. ListView was the only one I found that supporting paging. I liked the way the ListView and Repeater made it easy to lay out the data since I have about 15 columns and putting them all in a single row in a grid made it very wide.

3 & 4) I couldn''t figure out how to even get started with an edit or insert using the Repeater or the GridView. The ListView supports it with the EditItem template and UpdateItem templates, so that''s what I''ve been using. I can''t figure out with those how to show a field and show it read-only in the Edit if they shouldn''t edit it. I couldn''t figure out how to stop it from inserting if a field was empty.


我仍然没有运气来解决这个问题.谁能为我指出正确的方向...?
I still haven''t had any luck figuring this out. Can anyone point me the right direction on how to accomplish this...?


这篇关于ASP SQL WebForm-搜索,插入,编辑操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆