获取动态网格视图中的单元格值 [英] get value of a cell in a dynamic gridview

查看:73
本文介绍了获取动态网格视图中的单元格值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



大家的好日子,谢谢。我的网络应用程序需要帮助。我在动态网格视图中获取单元格值时遇到问题。谁能帮我这个?非常感谢...代码就在下面。

Hi to all,

Good day to everyone and thank you. I need help on my web app. I'm having a problem getting a value of a cell in a dynamic gridview. can anyone help me with this? thank you very much... the code is right below.

<asp:GridView ID="gvAttendance" runat="Server"

                      AllowPaging="True"

                      AutoGenerateColumns="true" PageSize="10"

                      SelectedIndex="0" Width="465px"

                      CssClass="mGrid" PagerStyle-CssClass="pgr"

                      AlternatingRowStyle-CssClass="alt"



                      DataSourceID="sqlDSAttendance" DataMember="DefaultView"

            onrowdatabound="gvAttendance_RowDataBound"

            onrowcommand="gvAttendance_RowCommand" >
            <EmptyDataTemplate>
                <asp:Label ID="lblNull" runat="Server"

                           ForeColor="Red"> There&#39;s no data to show in this view...
                </asp:Label>
            </EmptyDataTemplate>
        </asp:GridView>
    </div>
</div>
<asp:SqlDataSource ID="sqlDSAttendance" runat="server"

                   ConnectionString="<%$ ConnectionStrings:OTEConnString %>"

                   ProviderName="MySql.Data.MySqlClient"

                   SelectCommand = "CALL ote.pivotwizard('AgentID,AgentNo,Agent_Name','att_Date','att_Time','ote.view_attendance','((agent_name IS NOT NULL) OR (year(att_date)=2010))')">
</asp:SqlDataSource>

解决方案

ConnectionStrings:OTEConnString %>

< span class =code-attribute> ProviderName = MySql.Data.MySqlClient

SelectCommand < span class =code-keyword> = CALL ote.pivo twizard('AgentID,AgentNo,Agent_Name','att_Date','att_Time','ote.view_attendance','((agent_name IS NOT NULL)或(year(att_date)= 2010))') < span class =code-keyword>>
< / asp:SqlDataSource >
ConnectionStrings:OTEConnString %>" ProviderName="MySql.Data.MySqlClient" SelectCommand = "CALL ote.pivotwizard('AgentID,AgentNo,Agent_Name','att_Date','att_Time','ote.view_attendance','((agent_name IS NOT NULL) OR (year(att_date)=2010))')"> </asp:SqlDataSource>


您好b $ b

您可以获得动态创建的gridview的值,例如



这将返回Cell 1第1行的Gridview1的值

gridview1.rows [ 0] [0] .text





谢谢,

Imdadhusen
Hi
You can get the value of dynamically created gridview like

this will return value of Gridview1 of Row 1 of Cell 1
gridview1.rows[0][0].text


Thanks,
Imdadhusen


我不确定你在上下文中通过动态创建的网格是什么意思。



如果你这样创建控件,

I am not sure what do you mean by dynamucally created grid on that context.

If you are creating control like this way,
GridView grdView= new GridView();
grdView.DataSource=myDataSource;





您可以使用GridViewRows类访问GridRows





You can access the GridRows by using GridViewRows Class

GridViewRows gridviewRow= grdView.SelectedRow;





现在从gridviewRow获得价值对于该行的任何单元格,您也可以像Sunasara建议直接从Cell获取价值。



希望这对您有所帮助!



Now from gridviewRow you get value of any cell for that row, You can also go with as Sunasara suggested to get value directly from a Cell.

Hope this will help you !


这篇关于获取动态网格视图中的单元格值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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