如何在gridview及其处理程序中使用更新/编辑 [英] How to use the update/Edit in gridview and it's handlers

查看:63
本文介绍了如何在gridview及其处理程序中使用更新/编辑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,克里斯蒂安·格劳斯先生

感谢您对数据库设计的说明,我将按照您的建议进行修改,但问题仍然是更新后如何绑定数据,以及在知道必需的变量有关更新命令的信息将从预览页面(登录)中获取.如果有人可以给出代码示例,那就太好了.

感谢您提供有关此问题的任何意见.

再次感谢

--------------------------------------

再次嗨
格劳斯先生,请不要误会一个人的知识水平低于您的水平,而一个真正忙于阅读完整文章的人.

不要以为我对你在答案中写的东西不感激,因为我是.


动态添加列的问题将得到解决,因为该解决方案确实很容易做.

通过发布我的电子邮件,我不是以前那样依靠您为我提供必须完成的事情的完整解决方案的方法,我只是在寻找可以帮助解决本文中所讨论问题的信息.其他.

和张贴的电子邮件是临时的.用于我们项目的电子邮件,将在我们完成项目后立即停用,因此我真的不在乎垃圾邮件,因为它不是我的私人电子邮件.

至于我对数据库的天真性,那是因为这不是我的专长,我的专长是计算机网络与计算机专业.嵌入式系统.

再说一次,请不要把所有这些都当成忘恩负义.

Khalel

解决方案

但是,您没有提供用于更新网格中数据的处理程序函数...正如您在问题中所讨论的.

我的建议是,如果您需要通过表单或外部接口(然后是网格)更新或添加数据,则使用SqlCommand通过连接模式连接数据的方法是正确的,以防万一您需要在网格本身中添加或更新数据. ..那么最好使用数据绑定网格并使用SqlDataAdapter和Dataset.

使用SqlDataAdapter支持使用SqlCommandBuilder类,该类可用于添加或更新表中的数据.它简化了网格本身中数据的内联添加和更新.

因此,如果您可以从上述两个要求中唯一地指定您的需求,我会很容易为您提供相关的代码示例.遵循简单的指示吗?如果您无法从我所做的事情以及我所做的解释中得出的结论,都无法按答案"按钮来询问更多问题,那么为什么我会认为您有能力按照您所询问的更复杂的说明进行操作?我是为了什么?

Khalid57305写道:

使用过程是什么意思?



存储过程.您确定要在数据库中使用存储过程吗?如果不是,那么您在项目上的工作是如何创建一些表?

Khalid57305写道:

在讲师登录(该课堂上的指纹)后,在出席人数表中添加新列的问题是什么?日期作为列标题.



太疯狂了这是我从未听说过的最糟糕的数据库设计.登录的讲师应在表格中创建一行.表的架构不应更改.对不起,如果我们只是对术语感到困惑,但是如果您要添加一行,那么您的整个问题就很疯狂,因为在这种情况下,没有多余的列,也没有理由更改您的SQL,表示层或其他任何内容.

如果您正在按照自己说的去做,那么您甚至对数据库的用途或使数据库有用的用途甚至没有最基本的了解.

Khalid57305写道:

请耐心等待,因为我们不在我们的领域之内…….



好吧,我正在尝试提供帮助,但是当您打算上一堂课时,您怎么会如此完全迷失.讲师没有教你任何东西吗?

令人遗憾的是,删除邮件似乎又一次中断了,所以尽管我确实将其复制到主体中,但为了自己的方便,并再次向您展示了如何完成操作,所以我无法删除您的虚假答案" .我将尝试至少删除您的电子邮件地址.我不明白那里的人的整个发展计划似乎是围绕着随机陌生人的善意,以至于你以为我会给你发电子邮件.我会告诉你谁,这就是每一个在网上拖拉垃圾邮件的人,他们在寻找愚蠢的人来公开自己的地址.


我不明白你为什么"将每天在表格中添加列.在我看来,这似乎是一个破损的设计.每天都有人更新数据库架构吗?如果有人要更新数据库以添加列,为什么不让他们更新存储的一两个或多个过程以传递或返回这些列呢?您可以尝试编写代码,以便它动态地计算出列名,并且知道这些是要传入的变量名,但是您仍然需要更改编辑模板以允许您编辑新列. >
我想我对您要说的内容缺少一些非常基本的东西,因为对我来说这听起来不合逻辑且复杂.


Hello, Mr.Christian Graus

Thanks for your notes about the DB design, I will modify it as you suggested, but still the problem is how to bind the data after updating, and how to handle the Edit/Update Events knowing that the required Variables for the update command will be taken from the previews page (log in). it will be great if any one can give a code example.

I appreciate any inputs regarding this problem.

thanks again

--------------------------------------

Hi again
Mr.Graus, please don''t mistake a person to be below the level of your intellect, with a person who is really busy to go through a complete article.

Don''t think that I''m ungrateful for what you have written in your answers, because I am.


And the matter of dynamically adding a column will be resolved as for the solution is a really easy and simple thing to do.

And by posting my e-mail i wasn''t what so ever depending on you providing me with a full solution to something that i have to do, I was merely looking for some input that would help in the matters discussed in This post nothing else.

And the posted e-mail is a temp. e-mail used for our project and will be deactivated as soon as we finish our project and for that I really don''t care about spam, as it''s not my personal e-mail.

And as for my naiveness in database''s in general, it''s because that it''s not my specialty, where my specialty is Computer Networks & Embedded Systems.

And again, please don''t mistake all that as being ungrateful.

Khalel

解决方案

However, you did not provide your handler function which is used to update the data in grid... as you discussed in your question.

My suggestion is, if you need to update or add data through a form or external interface (then grid), your approach to connect data through connected mode using SqlCommand is correct and in case you need to add or update the data in grid itself... then better to use databound grid and use SqlDataAdapter and Dataset.

Use of SqlDataAdapter supports the use of SqlCommandBuilder Class which can be used to add or update the data in table. It ease the inline addition and updation of data in grid itself.

So if you could uniquely specify your need from above two requirements, I will find ease to supply relevant code example to you.


Hello khalel - why is it both you and your partner can''t follow simple instructions ? If you couldn''t work out from what I did and what I explained to NOT push the ''answer'' button to ask more questions, why would I assume you had any capability of following the more complex instructions you''re asking me for ?

Khalid57305 wrote:

what did you mean by using a procedure??



A stored procedure. Surely you''re using stored procedures in your database ? If not, what is your job on the project, to create some tables ?

Khalid57305 wrote:

what is the problem with adding a new column in the attendance table upon lecturer sign-in (Fingerprint, in class) with that lecture''s date as the column''s caption.



It''s insane. It''s the worst database design I''ve ever heard of. The lecturer signing in should create a row in the table. The schema of the table should not change. I''m sorry if we just have some confusion over terminology, but if you''re adding a row, then your whole question is insane, because in that case, there is no extra column and no reason to change your SQL, your presentation layer, or anything else.

If you''re doing what you say you''re doing, then you have not even the most basic idea of what a database is for, or what makes it useful.

Khalid57305 wrote:

please bear with us, as we are out of our field.......



Well, I am trying to help, but how can you be so totally lost when this is meant to be for a class. Did the lecturer not teach you anything ?

Sadly, deleting messages seems to have broken again, so I can''t delete your fake ''answer'', although I did copy it into the main body, for my own convenience, and to show you AGAIN how it should be done. I will try to at least remove your email address. I don''t get how there''s people whose entire development plan seems to revolve around the kindness of random strangers, to the point that you think I''d email you. I''ll tell you who will, and that''s every spammer who trawls the web looking for people dumb enough to make their address public.


I don''t see why you''d be adding columns to your table daily. That seems like a broken design to me. Every day, someone updates the database schema ? If someone is updating the database to add a column, why not have them update a stored proc or two to pass in or return those columns ? You could try to write your code so it dynamically works out the column names and knows those are the variable names to pass in, but you''d still need to change your edit template to allow you to edit the new column.

I think I''m missing something very fundamental about what you''re trying to say, because it sounds illogical and complex to me right now.


这篇关于如何在gridview及其处理程序中使用更新/编辑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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