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