////////this is CreateVideoDataSet()
private DataSet CreateVideoDataSet()
{
try
{ //id,videfilename,videopath,Attachment path,attachmentName,course title
DataSet dsNewVideo = new DataSet();
DataTable dt = new DataTable();
DataColumn dc;
dc = new DataColumn();
dc.DataType = System.Type.GetType("System.Int64");
dc.ColumnName = "Id";
dc.Unique = true;
dt.Columns.Add(dc);
dc = new DataColumn();
dc.DataType = System.Type.GetType("System.String");
dc.ColumnName = "VideoFileName";
dc.Unique = false;
dt.Columns.Add(dc);
dc = new DataColumn();
dc.DataType = System.Type.GetType("System.String");
dc.ColumnName = "VideoPath";
dc.Unique = false;
dt.Columns.Add(dc);
dc = new DataColumn();
dc.DataType = System.Type.GetType("System.String");
dc.ColumnName = "AttachmentPath";
dc.Unique = false;
dt.Columns.Add(dc);
dc = new DataColumn();
dc.DataType = System.Type.GetType("System.String");
dc.ColumnName = "AttachmentName";
dc.Unique = false;
dt.Columns.Add(dc);
dc = new DataColumn();
dc.DataType = System.Type.GetType("System.String");
dc.ColumnName = "CourseTitle";
dc.Unique = false;
dt.Columns.Add(dc);
dc = new DataColumn();
dc.DataType = System.Type.GetType("System.Boolean");
dc.ColumnName = "IsAvailableToAll";
dc.Unique = false;
dt.Columns.Add(dc);
dsNewVideo.Tables.Add(dt);
return dsNewVideo;
}
//in the page load
public void FillDataToGrid()
{
try
{
IVideo objIVideo = new IVideo();
DsMediaFiles = objIVideo.GetAvailableVideos();
DataSet dsNewVideo = CreateVideoDataSet();
foreach (DataRow dr in DsMediaFiles.Tables[0].Rows)
{
string LotNos = string.Empty;
DataRow[] found = DsMediaFiles.Tables[0].Select("Id=" + Convert.ToInt32(dr["Id"]));
if (found.Length > 0)
{
for (int i = 0; i < found.Length; i++)
{
LotNos += found[i]["CourseTitle"].ToString() + ",";
}
DataRow[] drows = dsNewVideo.Tables[0].Select("id=" + Convert.ToInt32(dr["id"]));
if (drows.Length == 0)
{
DataRow row1 = dsNewVideo.Tables[0].NewRow();
row1["Id"] = dr["Id"];
row1["VideoFileName"] = dr["VideoFileName"];
row1["VideoPath"] = dr["VideoPath"];
row1["AttachmentPath"] = dr["AttachmentPath"];
row1["AttachmentName"] = dr["AttachmentName"];
row1["IsAvailableToAll"] = dr["IsAvailableToAll"];
row1["CourseTitle"] = LotNos.TrimEnd(',');
if (row1["IsAvailableToAll"].ToString() == "True")
{
row1["CourseTitle"] = "";
}
dsNewVideo.Tables[0].Rows.Add(row1);
}
}
}
if (dsNewVideo != null && dsNewVideo.Tables[0].Rows.Count > 0)
{
gvAvailableVideos.DataSource = dsNewVideo.Tables[0];
gvAvailableVideos.DataBind();
Session["DsMediaFiles"] = dsNewVideo;
}
else
{
gvAvailableVideos.DataSource = null;
gvAvailableVideos.DataBind();
TrNoRecords.Visible = true;
gvAvailableVideos.Visible = false;
}
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment