list两种取值方式

使用for或才foreach取值。代码如下:

protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string cmID=string.Empty; string cmuid=string.Empty; cmID = "1"; cmuid = "1"; getCmptModel gcm = new getCmptModel(); List cmodel = gcm.GetModuleCmpt(cmID, cmuid); for (int i = 0; i < 5; i++) { litTabsLi.Text += "

  • " + i.ToString() + "
  • "; litTablDiv.Text += "

    " + cmodel[i].QuestionnaireName + "

    "; } //foreach (var item in cmodel) //{ // //litTabsLi.Text += "
  • " + item.Id.ToString() + "
  • "; // litTablDiv.Text += "

    " + item.QuestionnaireName + ","+item.QuestionnaireId.ToString()+"

    "; //} } }

    你可能感兴趣的:(ASP.NET)