Пример #1
0
        public void bindgriddata()
        {
            DataSet ds = new DataSet();
            NewsService.FeedServiceClient client = new NewsService.FeedServiceClient();
            ds = client.GetNews();
            GridView1.DataSource = ds;
            GridView1.DataBind();

        }
Пример #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                DataSet ds = new DataSet();
                NewsService.FeedServiceClient client = new NewsService.FeedServiceClient();
                ds = client.GetNews();
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    try
                    {
                        DataRow r = ds.Tables[0].Rows[i];

                        Label title = new Label();
                        title.Text = "<b><p style=font-size:30px;font-family:verdana>" + r.Field <String>(2) + "</p></b>";
                        newspanel.Controls.Add(title);

                        Label author = new Label();
                        author.Text = "<p style=color:red;font-size:12px>By " + r.Field <String>(1) + "</p>";
                        newspanel.Controls.Add(author);

                        Label date = new Label();
                        date.Text = "<p>Updated on : " + r.Field <DateTime>(3) + "</p>";
                        newspanel.Controls.Add(date);

                        Image  image     = new Image();
                        byte[] bytes     = r.Field <byte[]>(6);
                        string strBase64 = Convert.ToBase64String(bytes);
                        image.ImageUrl = "data:Image/png;base64," + strBase64;
                        image.Width    = 300;
                        image.Height   = 300;
                        newspanel.Controls.Add(image);

                        Label newline1 = new Label();
                        newline1.Text = "<br><br>";
                        newspanel.Controls.Add(newline1);

                        Label content = new Label();
                        content.Text = "<p width:500px;height:100px;border:1px solid #000; style=color:grey;font-family:Courier New>" + r.Field <String>(4) + "</p>";
                        newspanel.Controls.Add(content);

                        string url  = r.Field <String>(7);
                        Label  link = new Label();
                        link.Text = "Video Link : <a href=" + url + " target = blank>" + url + "</a>" + "<br><br>";
                        newspanel.Controls.Add(link);

                        Label hrline = new Label();
                        hrline.Text = "<hr>";
                        newspanel.Controls.Add(hrline);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex);
                    }
                }
            }
        }
Пример #3
0
        protected void dltbtn_Click(object sender, EventArgs e)
        {
            NewsService.FeedServiceClient client = new NewsService.FeedServiceClient();
            NewsService.News news = new NewsService.News();
            news.NewsID = TextBox.Text.Trim();
            string result = client.DeleteNews(news);

            if (result == "News Deleted Successfully!")
            {
                bindgriddata();
                deletelabel.Text = "News ID : " + TextBox.Text.Trim() + " Deleted Successfully !";
            }
            else
            {
                deletelabel.Text = "News ID : " + TextBox.Text.Trim() + " Not Found !";
            }
        }
Пример #4
0
 protected void add_news_Click(object sender, EventArgs e)
 {
     try
     {
         byte[]           bytes;
         NewsService.News nw = new NewsService.News();
         nw.NewsID      = newsId.Text;
         nw.Authorname  = author.Text;
         nw.Title       = ntitle.Text;
         nw.PublishDate = Convert.ToDateTime(publishdate.Text);
         nw.Content     = content.Text;
         HttpPostedFile postedFile    = imageUpload.PostedFile;
         string         filename      = Path.GetFileName(postedFile.FileName);
         string         fileExtension = Path.GetExtension(filename);
         int            fileSize      = postedFile.ContentLength;
         nw.Category  = categorylist.SelectedValue;
         nw.VideoLink = link.Text;
         Console.WriteLine(fileExtension);
         if (fileExtension.ToLower() == ".jpeg" || fileExtension.ToLower() == ".png" || fileExtension.ToLower() == ".jpg" || fileExtension.ToLower() == ".jfif")
         {
             Stream       stream       = postedFile.InputStream;
             BinaryReader binaryReader = new BinaryReader(stream);
             bytes        = binaryReader.ReadBytes((int)stream.Length);
             nw.NewsImage = bytes;
             Console.WriteLine(bytes);
             NewsService.FeedServiceClient client = new NewsService.FeedServiceClient();
             success.Text = "News Id : " + nw.NewsID + " " + client.AddNews(nw);
         }
         else
         {
             error.Text = "Image may be not in proper format.";
         }
     }
     catch (Exception ex)
     {
         success.Text = "News ID must be unique! or Error";
     }
 }