| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2119 人关注过本帖
标题:GridView1_RowCommand 中取 ButtonField 的 各个值~~【**DisSun**】50分
取消只看楼主 加入收藏
dissun
Rank: 2
等 级:论坛游民
帖 子:59
专家分:61
注 册:2009-9-8
结帖率:85.71%
收藏
已结贴  问题点数:50 回复次数:4 
GridView1_RowCommand 中取 ButtonField 的 各个值~~【**DisSun**】50分
本人接触不久。有些弱智问题要问。能解答的请不吝解答下。
这个问题已经困扰我一天了,下入正题。

程序代码:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
                DataSourceID="Sqlnews" Width="907px" EmptyDataText="现在还没有任何信息"
                onrowdatabound="GridView1_RowDataBound"
                onrowcommand="GridView1_RowCommand">
                <Columns>
                    <asp:TemplateField HeaderText="审核">
                        <EditItemTemplate>
                            <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("disp") %>'></asp:TextBox>
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:LinkButton ID="LBdisp" CommandArgument='<%#Eval("id") %>' runat="server"
                                Font-Underline="False" oncommand="LBdisp_Command"></asp:LinkButton>
                        </ItemTemplate>
                    </asp:TemplateField> 

                    ///需要修改的字段***************************
                    <asp:ButtonField HeaderText="热点" DataField="hot"  CommandName="BFhot"  Text="yes" />
                    ///需要修改的字段结束*******************************

                    <asp:BoundField DataField="date" HeaderText="创建时间" SortExpression="date" />
                    <asp:HyperLinkField HeaderText="操作" Text="修改" />
                </Columns>
            </asp:GridView>

   
程序代码:
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        int rowIndex = Convert.ToInt16();
        GridViewRow row=GridView1.Rows[rowIndex];

        if ( == "BFhot")
        {
            string hot = GridView1.Rows[rowIndex].Cells[4].Text;       
            Response.Write("<script >alert('数据修改完成!*" + hot+ "');</script>");       
        }
     }


我希望在ROW_COMMAND中取得“热点”ButtonField的 Text值,还有就是 跟这个ButtonField绑定的数据字段"hot"的值。
但是我又不想把 这个ButtonField放在TemplateField里面。请问有办法吗。


[ 本帖最后由 dissun 于 2010-4-2 11:15 编辑 ]
搜索更多相关主题的帖子: RowCommand DisSun ButtonField 
2010-04-02 11:00
dissun
Rank: 2
等 级:论坛游民
帖 子:59
专家分:61
注 册:2009-9-8
收藏
得分:0 
帮主们,你们也不理我啊....解决不了吗?...
2010-04-02 15:10
dissun
Rank: 2
等 级:论坛游民
帖 子:59
专家分:61
注 册:2009-9-8
收藏
得分:0 
回复 楼主 dissun
RowCommand中的代码是错的,我试着取出 每行,第4列 的 ButtonField 的值,但不行,所以你可以不理,

只要能在RowCommand行为中 取出 ButtonField 的Text和与之绑定的字段值“hot”就行。
2010-04-03 15:37
dissun
Rank: 2
等 级:论坛游民
帖 子:59
专家分:61
注 册:2009-9-8
收藏
得分:0 
老大爷,拜托~ 说了我接触不久。。。
你就写写代码,让俺看看嘛~~
是不是这样:
 string hot =((Button) GridView1.Rows[rowIndex].Cells[4].Controls[0]).Text;  
2010-04-03 19:15
dissun
Rank: 2
等 级:论坛游民
帖 子:59
专家分:61
注 册:2009-9-8
收藏
得分:0 
看来无望了,结贴。
虽然无法解决问题,Thank you all the same楼上的。
2010-04-06 20:10
快速回复:GridView1_RowCommand 中取 ButtonField 的 各个值~~【**DisSun**】50 ...
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.021130 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved