一个取得数据控件模板中输入框值的类
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;
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
/**//// <summary>
/// GetEdit 的摘要说明
/// </summary>
public class GetEdit
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
{
private static int RowsIndex;
public GetEdit()
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <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)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
return ((System.Web.UI.WebControls.TextBox)GridViewID.Rows[RowsIndex].Cells[CellIndex].FindControl(TextBoxID)).Text;
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
public static string GetGridView_TextBox(GridView GridViewID, string TextBoxID, GridViewCommandEventArgs e, int CellIndex)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
RowsIndex = Convert.ToInt32(e.CommandArgument);
return ((System.Web.UI.WebControls.TextBox)GridViewID.Rows[RowsIndex].Cells[CellIndex].FindControl(TextBoxID)).Text;
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
/// 取GridView中HiddenField中的值
/// </summary>
public static string GetGridView_HiddenField(GridView GridViewID, string HiddenFieldID, int RowsIndex, int CellIndex)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
return ((System.Web.UI.WebControls.HiddenField)GridViewID.Rows[RowsIndex].Cells[CellIndex].FindControl(HiddenFieldID)).Value;
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
public static string GetGridView_HiddenField(GridView GridViewID, string HiddenFieldID, GridViewCommandEventArgs e, int CellIndex)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
RowsIndex = Convert.ToInt32(e.CommandArgument);
return ((System.Web.UI.WebControls.HiddenField)GridViewID.Rows[RowsIndex].Cells[CellIndex].FindControl(HiddenFieldID)).Value;
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
/// 取DataList中TextBox中的值
/// </summary>
public static string GetDataList_TextBox(DataList DataListID, string TextBoxID, DataListCommandEventArgs e)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
return ((System.Web.UI.WebControls.TextBox)DataListID.Items[e.Item.ItemIndex].FindControl(TextBoxID)).Text;
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
/// 取DataList中HiddenField中的值
/// </summary>
public static string GetDataList_HiddenField(DataList DataListID, string HiddenFieldID, DataListCommandEventArgs e)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
return ((System.Web.UI.WebControls.HiddenField)DataListID.Items[e.Item.ItemIndex].FindControl(HiddenFieldID)).Value;
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
/// 取Repeater中TextBox中的值
/// </summary>
public static string GetRepeater_TextBox(Repeater RepeaterID, string TextBoxID, RepeaterCommandEventArgs e)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
return ((System.Web.UI.WebControls.TextBox)RepeaterID.Items[e.Item.ItemIndex].FindControl(TextBoxID)).Text;
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
/// 取Repeater中HiddenField中的值
/// </summary>
public static string GetRepeater_HiddenField(Repeater RepeaterID, string HiddenFieldID, RepeaterCommandEventArgs e)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
return ((System.Web.UI.WebControls.HiddenField)RepeaterID.Items[e.Item.ItemIndex].FindControl(HiddenFieldID)).Value;
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
/// 取FormView中HiddenField中的值
/// </summary>
public static string GetFormView_TextBox(FormView FormViewID, string TextBoxID)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
return ((System.Web.UI.WebControls.TextBox)FormViewID.FindControl(TextBoxID)).Text;
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
/// 取FormView中TextBox中的值
/// </summary>
public static string GetFormView_Hidden(FormView FormViewID, string TextBoxID)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
return ((System.Web.UI.WebControls.HiddenField)FormViewID.FindControl(TextBoxID)).Value;
}
}
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
原文地址:https://www.cnblogs.com/yeagen/p/1332205.html