using System;
using System.Linq;
using System.Data;
public partial class GetIenumerablevalues : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnGetValues_Click(object sender, EventArgs e)
{
DataTable dt = new DataTable();
dt.Columns.Add("UserId", typeof(Int32));
dt.Columns.Add("UserName", typeof(string));
dt.Columns.Add("Education", typeof(string));
dt.Rows.Add(1, "Suresh Dasari", "B.Tech");
dt.Rows.Add(2, "Rohini Dasari", "Msc");
dt.Rows.Add(3, "Madhav Sai", "MS");
dt.Rows.Add(4, "Praveen", "B.Tech");
dt.Rows.Add(6, "Sateesh", "MD");
dt.Rows.Add(7, "Mahesh Dasari", "B.Tech");
dt.Rows.Add(8, "Mahendra", "CA");
var data = dt.AsEnumerable().Select(row =>
new
{
UserId = row["UserId"].ToString(),
UserName = row["UserName"].ToString(),
Education = row["Education"].ToString()
});
foreach (var row in data)
{
lblval.Text += "UserId: "+row.UserId+", Name: " +row.UserName+", Value: "+row.Education+"<br/>";
}
}
}
|
1 comments:
Write commentsSpecial chars is not display correctly
ReplyConversionConversion EmoticonEmoticon