• griview获取当前行的任意一个单元的值


    HTML:

    <asp:GridView ID="GrvQuerySingInfo" runat="server" AutoGenerateColumns="False" >   
    <Columns>
    <asp:TemplateField HeaderText="ID" Visible="false">
                        <EditItemTemplate>
                            <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("UserID") %>'></asp:TextBox>
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:Label ID="LabID" runat="server" Text='<%# Bind("UserID") %>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
     <asp:TemplateField HeaderText="详细" ShowHeader="False">
                        <ItemTemplate>
                            <asp:LinkButton ID="lingk" runat="server" CausesValidation="false" 
                                CommandName="Detail" onclick="lingk_Click">详细</asp:LinkButton>
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
            </asp:GridView>
     

    后台C#:

    protected void LingkApply_Click(object sender, EventArgs e)
            {
               GridViewRow gvr = (sender as LinkButton).NamingContainer as GridViewRow;
               if (gvr != null)
               {
                   Label user = (Label)gvr.FindControl("LabID");//获取当前行的“LabId”
                   Label SignId = (Label)gvr.FindControl("LabSign");
                   Label Name = (Label)gvr.FindControl("lblfullname");
                   Label date = (Label)gvr.FindControl("labdate");
                   string userid = user.Text;
                   string datetime = date.Text;
                   string name = Name.Text;
                   string signid = SignId.Text;
                   Response.Redirect("ApplyForSign.aspx?userid=" + userid + "&time=" + datetime + "&type=apply" + "&name=" + name + "&SignId="+ signid);
               }
    
            }
  • 相关阅读:
    20150112-夜深,人不静
    20150111-谁会记得
    20150110-我希望我的歌声里都是希望
    20150102-霰现
    20150116-卵子
    20150109-放弃了一切希望
    20150105-条大路哟
    笔记:使用 stylus stylus-loader
    如何处理烫伤的伤口?
    连电子硬件行业都在开始使用 Git 了你还在等什么?
  • 原文地址:https://www.cnblogs.com/fuge/p/2611787.html
Copyright © 2020-2023  润新知