我想从数据集中检索最小值和最大值,这些值在 for 循环中用于在面板中显示标题
String sql = "select title, song_id from up_song where Song_type='Mp3 Tracks' ";
SqlDataAdapter adpt = new SqlDataAdapter(sql, cn);
DataSet ds = new DataSet();
adpt.Fill(ds, "title");
所以在这里我想找到歌曲ID的最小值和最大值......这里m是最大值和k最小值我不知道......我如何选择k和m......?
for (i = m; i >= k; --i)
{
try
{
hp[i] = new HyperLink();
hp[i].ID = "hp" + i;
hp[i].Text = ds.Tables["title"].Rows[i].ItemArray[0].ToString();
hp[i].NavigateUrl = "Downloadpage.aspx";
hp[i].ForeColor = System.Drawing.Color.White;
Panel1.Controls.Add(hp[i]);
Panel1.Controls.Add(new LiteralControl("<br>"));
HttpCookie coo = new HttpCookie("song");
coo["sogtit"] = ds.Tables["title"].Rows[i].ItemArray[0].ToString();
Response.Cookies.Add(coo);
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
}