private void GetTagInQuestions() { List<QATag> taglist = new List<QATag>(); string Question = Request.QueryString["QuestionId"]; try { SqlCommand cmdKljucneRijeci = new SqlCommand("GetTagInQuestions"); cmdKljucneRijeci.CommandType = CommandType.StoredProcedure; cmdKljucneRijeci.Connection = connection; cmdKljucneRijeci.Parameters.AddWithValue("@QuestionId", Convert.ToInt32(Question)); connection.Open(); SqlDataAdapter daKljucneRijeci = new SqlDataAdapter(cmdKljucneRijeci); SqlDataReader readerKljucneRijeci = cmdKljucneRijeci.ExecuteReader(); while (readerKljucneRijeci.Read()) { lblKljucneRijeci.Text = lblKljucneRijeci.Text + " | " + readerKljucneRijeci["Tag"].ToString() + ""; QATag tag = new QATag(); tag.Name = readerKljucneRijeci["Tag"].ToString() ; taglist.Add(tag); } //rprTags.DataSource = taglist; //rprTags.DataBind(); readerKljucneRijeci.Close(); } catch (Exception ex) { // MessageBox.Show("Greska!", "Important Message"); ClientScript.RegisterStartupScript(typeof(Page), "myscript", "alert('Failed Tags!');", true); } finally { connection.Close(); } }
protected void Page_Load(object sender, EventArgs e) { string username = (string)Session["Username"]; string Question = Request.QueryString["QuestionId"]; string numviews = "0"; showAnswers(Convert.ToInt32(Question)); List<QAQuestion> questionbody = new List<QAQuestion>(); QAQuestion question = new QAQuestion(); QAAnswer answer = new QAAnswer(); List<QAAnswer> answerlist = new List<QAAnswer>(); QATag tag = new QATag(); if (!IsPostBack) { DataSet ds = new DataSet(); connection.Open(); SqlCommand cmd = new SqlCommand("SELECT dbo.Question.QuestionId As QuestionId, dbo.Question.QuestionTitle AS QuestionTitle, dbo.Question.QuestionBody AS QuestionBody, dbo.Question.CreatedDate AS CreatedDate,dbo.Question.NumOfViews AS NumOfViews, dbo.Users.UserId AS UserId, dbo.Users.Firstname, dbo.Users.Lastname, dbo.Users.Username" + " FROM dbo.Question INNER JOIN dbo.Users ON dbo.Question.UserId = dbo.Users.UserId WHERE dbo.Question.QuestionId=" + Question, connection); SqlDataAdapter da = new SqlDataAdapter(cmd); da.Fill(ds); refreshVotingData(); List<QATag> taglist = new List<QATag>(); //rprTags.DataSource = taglist; //rprTags.DataBind(); SqlDataReader reader = cmd.ExecuteReader(); if (reader.Read()) { if (reader["NumOfViews"].ToString() != "") numviews = reader["NumOfViews"].ToString(); else numviews = "0"; question.QuestionTitle = reader["QuestionTitle"].ToString(); question.QuestionBody = reader["QuestionBody"].ToString(); question.NumOfViews = Convert.ToInt32(reader["NumOfViews"].ToString()); if (reader["NumOfViews"].ToString() != "") numviews = reader["NumOfViews"].ToString(); else numviews = "0"; questionbody.Add(question); Repeater1.DataSource = questionbody; Repeater1.DataBind(); lblDate.Text = reader["CreatedDate"].ToString(); lblAutor.Text = reader["Firstname"].ToString() + " " + reader["Lastname"].ToString() + ""; reader.Close(); connection.Close(); UpdateViews(numviews); } lblKljucneRijeci.Text = ""; GetTagInQuestions(); connection.Close(); //////Recommend StackOverflow StackOverflowRecommendation(taglist, question.QuestionTitle); } }