0
下面是我有的代码,它与可见列完美配合。不过,我需要能够得到某些列是看不到的价值:如何从隐藏列中获取值?
protected void btnSearchForSchedules_Click(object sender, EventArgs e)
{
var ds = new DataSet();
var schedulesTable = new DataTable();
foreach (GridViewRow gvr in gvShows.Rows)
{
if (gvr.RowType == DataControlRowType.DataRow)
{
if (((CheckBox) gvr.FindControl("cbSelect")).Checked)
{
string baseURL = WebConfigurationManager.AppSettings["SchedulesAPI"];
string dataSource = gvr.Cells[1].Text;
string showId = gvr.Cells[2].Text; //this column is hidden so I'm getting a NULL here
string episodeId = gvr.Cells[4].Text;
string callingURL = baseURL + "?datasource=" + dataSource + "&showid=" + showId;
if (episodeId != " ")
{
callingURL = callingURL + "&episodeId=" + episodeId;
}
schedulesTable = Transporter.GetDataTableFromAPI(callingURL);
ds.Tables.Add(schedulesTable);
}
}
}
任何人都可以向我解释,我怎么可以这样做:
串showId = gvr.Cells [2] 。文本;
如果该列不可见?
http://stackoverflow.com/q/4127662/2387010 – Chris
的可能的复制,我看到其他的问题,但我不知道如何让它在我的代码工作。 –
这个http://social.msdn.microsoft.com/Forums/en-US/winformsdatacontrols/thread/e7bf9a9c-f5c6-4b03-8481-652dc1c9d7b0/会有帮助吗? – Chris