• 一个取得数据控件模板中输入框值的类


    GetEdit.cs

    using System;
    using System.Data;
    using System.Configuration;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    using System.Data.SqlClient;
    using System.Web.UI.MobileControls;

    /// <summary>
    /// GetEdit 的摘要说明
    /// </summary>

    public class GetEdit
    {
        
    private static int RowsIndex;
        
    public GetEdit()
        
    {
            
        }


        
    /// <summary>
        
    /// 取GridView中TextBox中的值
        
    /// </summary>

        //按钮上设置属性  CommandArgument='<%# ((GridViewRow) Container).RowIndex %>'
        
    //int RowsIndex = Convert.ToInt32(e.CommandArgument);
        public static string GetGridView_TextBox(GridView GridViewID, string TextBoxID, int RowsIndex, int CellIndex)
        
    {
            
    return ((System.Web.UI.WebControls.TextBox)GridViewID.Rows[RowsIndex].Cells[CellIndex].FindControl(TextBoxID)).Text;
        }


        
    public static string GetGridView_TextBox(GridView GridViewID, string TextBoxID, GridViewCommandEventArgs e, int CellIndex)
        
    {
            RowsIndex 
    = Convert.ToInt32(e.CommandArgument);
            
    return ((System.Web.UI.WebControls.TextBox)GridViewID.Rows[RowsIndex].Cells[CellIndex].FindControl(TextBoxID)).Text;
        }


        
    /// <summary>
        
    /// 取GridView中HiddenField中的值
        
    /// </summary>

        public static string GetGridView_HiddenField(GridView GridViewID, string HiddenFieldID, int RowsIndex, int CellIndex)
        
    {
            
    return ((System.Web.UI.WebControls.HiddenField)GridViewID.Rows[RowsIndex].Cells[CellIndex].FindControl(HiddenFieldID)).Value;
        }


        
    public static string GetGridView_HiddenField(GridView GridViewID, string HiddenFieldID, GridViewCommandEventArgs e, int CellIndex)
        
    {
            RowsIndex 
    = Convert.ToInt32(e.CommandArgument);
            
    return ((System.Web.UI.WebControls.HiddenField)GridViewID.Rows[RowsIndex].Cells[CellIndex].FindControl(HiddenFieldID)).Value;
        }


        
    /// <summary>
        
    /// 取DataList中TextBox中的值
        
    /// </summary>

        public static string GetDataList_TextBox(DataList DataListID, string TextBoxID, DataListCommandEventArgs e)
        
    {
            
    return ((System.Web.UI.WebControls.TextBox)DataListID.Items[e.Item.ItemIndex].FindControl(TextBoxID)).Text;
        }


        
    /// <summary>
        
    /// 取DataList中HiddenField中的值
        
    /// </summary>

        public static string GetDataList_HiddenField(DataList DataListID, string HiddenFieldID, DataListCommandEventArgs e)
        
    {
            
    return ((System.Web.UI.WebControls.HiddenField)DataListID.Items[e.Item.ItemIndex].FindControl(HiddenFieldID)).Value;
        }


        
    /// <summary>
        
    /// 取Repeater中TextBox中的值
        
    /// </summary>

        public static string GetRepeater_TextBox(Repeater RepeaterID, string TextBoxID, RepeaterCommandEventArgs e)
        
    {
            
    return ((System.Web.UI.WebControls.TextBox)RepeaterID.Items[e.Item.ItemIndex].FindControl(TextBoxID)).Text;
        }


        
    /// <summary>
        
    /// 取Repeater中HiddenField中的值
        
    /// </summary>

        public static string GetRepeater_HiddenField(Repeater RepeaterID, string HiddenFieldID, RepeaterCommandEventArgs e)
        
    {
            
    return ((System.Web.UI.WebControls.HiddenField)RepeaterID.Items[e.Item.ItemIndex].FindControl(HiddenFieldID)).Value;
        }


        
    /// <summary>
        
    /// 取FormView中HiddenField中的值
        
    /// </summary>

        public static string GetFormView_TextBox(FormView FormViewID, string TextBoxID)
        
    {
            
    return ((System.Web.UI.WebControls.TextBox)FormViewID.FindControl(TextBoxID)).Text;
        }


        
    /// <summary>
        
    /// 取FormView中TextBox中的值
        
    /// </summary>

        public static string GetFormView_Hidden(FormView FormViewID, string TextBoxID)
        
    {
            
    return ((System.Web.UI.WebControls.HiddenField)FormViewID.FindControl(TextBoxID)).Value;
        }

    }

  • 相关阅读:
    python 单例模式
    JAVA基础知识总结
    java环境配置
    VScode输出中文乱码的解决方法------测试过可以用
    centos7 单独安装pip
    pyqt5信号与槽
    桌面程序显示到前台
    下载哔哩哔哩视频
    pyqt5 designer安装步骤
    树莓派配置静态wifi地址
  • 原文地址:https://www.cnblogs.com/yeagen/p/1332205.html
Copyright © 2020-2023  润新知