传递gridview单元格值 [英] Passing gridview cell value

查看:56
本文介绍了传递gridview单元格值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好亲爱的CPers,

我有一个gridview,其中有一些列,这些列用于从Db和templatefield检索数据.在此模板字段中,我有一个链接按钮.参见代码:

Hello dear CPers,

I have a gridview which has some columns where I retrieve data from Db and also a templatefield. In this template field I have a link button. see code:

<asp:TemplateField>
    <ItemTemplate>
        <asp:LinkButton ID="btnReceiveRMA" runat="server" CausesValidation="False" CommandName="btnReceiveRMA" Text="Receive" CommandArgument="<%# Container.DataItemIndex %>" OnClientClick="calculateDate(variable);"></asp:LinkButton>
    </ItemTemplate>
</asp:TemplateField>



我的意图是单击此链接按钮时,我需要从该行中获取日期值,并将该值与今天的日期进行比较,如果该值大于X,则需要有一个确认框,如果答案为确认框的确定还可以,我需要做更多的工作.



My intention is when clicked on this link button, i need to get the date value from that row and compare that value with today''s date, and if it is more than X, I need to have a confirm box, if the answer of this confirm box is ok i need more process to be done.

推荐答案

不要将任何数据从UI传递给函数.您需要有一个单独的数据层,并从数据层而不是从UI传递数据.另外,数据计算有什么问题?您是否使用ADO.NET和任何数据适配器的Fill方法?填写后,您可以使用数据表进行时间计算.在数据层中拥有数据库数据之后,应该使用它通过数据绑定(而不是相反)来填充UI.

我建议您学习以下架构模式:
MVVM —模型视图视图模型,
http://en.wikipedia.org/wiki/Model_View_ViewModel [> http://en.wikipedia.org/wiki/Model-view-controller [ ^ ])),

MVA —模型视图适配器,
http://en.wikipedia.org/wiki/Model–view–adapter [ ^ ],

MVP —模型视图呈现器,
> http://en.wikipedia.org/wiki/Model-view-presenter [ ^ ].
如果您分析它们并且在考虑您的应用程序时,它可能会帮助您提出更好的设计思想,从而使您提出的问题微不足道.整个方法应该有所不同.

祝你好运,
—SA
Don''t pass any data from UI to a function. You need to have a separate data layer and pass data from the data layer, not from UI. Also, what is the problem with data calculation? Do you use ADO.NET and any data adapter''s Fill methods? You can do time calculation with your data table after you fill it. After you have database data in your data layer, it should be used to populate the UI via data binding, not the other way around.

I suggest you learn the following architectural patterns:
MVVM — Model View View Model,
http://en.wikipedia.org/wiki/Model_View_ViewModel[^],

MVC — Model-View-Controller,
http://en.wikipedia.org/wiki/Model-view-controller[^]),

MVA — Model-View-Adapter,
http://en.wikipedia.org/wiki/Model–view–adapter[^],

MVP — Model-View-Presenter,
http://en.wikipedia.org/wiki/Model-view-presenter[^].
If you analyze them and while thinking about your application, it might help you to come up with better design ideas which would render the question you are asking insignificant. The whole approach should be different.

Good luck,
—SA


你好朋友..

要传递选定单元格的值,您需要从页面后面的代码而不是从UI端传递它.

为您提供帮助,它会为您提供一个当前选中行的单元格的值..

Hello Friend..

For passing a value of selected cell you need to pass it from your code behind page not from a UI side.

for you help see this it will give you a value of cell who''s row is currently selected..

grdDisplay.SelectedRow.Cells[0].Text



这里在Cells [0]中,0是您想要的值的列的索引..像在网格中一样,您有10列,然后,如果您要传递Date列的值,并且它的索引是8,则必须这样编写..



here in Cells[0], 0 is the index of column which value you want.. like in your grid you have 10 columns then if you want to pass a value of Date column and its index is 8 then you have to write like this..

grdDisplay.SelectedRow.Cells[8].Text


grd.SelectedRow .Cells [int your column no] .Text
grd.SelectedRow.Cells[int your column no].Text


这篇关于传递gridview单元格值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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