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;
}
}
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;
}
}