protected void SearchProvider(object sender, EventArgs e) { DataSet ds = GetData(); RepeaterComment.DataSource = ds; RepeaterComment.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Session["UserId"] != null) { RepeaterComment.DataSource = GetComments("Select c.Id,c.Comment,c.Likes,u.Name,u.Image from tblComments as c inner join tblUsers as u on u.Id=c.SenderId order by c.Id desc"); RepeaterComment.DataBind(); } else { Response.Redirect("Login.aspx"); } } }
private void bindrepeater() { string query = "SELECT * FROM hospitaldb.doctortable"; MySqlConnection con = new MySqlConnection(cs); MySqlCommand cmd = new MySqlCommand(); cmd.CommandText = query; cmd.Connection = con; MySqlDataAdapter sda = new MySqlDataAdapter(); DataSet ds = new DataSet(); sda.SelectCommand = cmd; sda.Fill(ds, "doctortable"); RepeaterComment.DataSource = ds; RepeaterComment.DataBind(); }
protected void Comment_Click(object sender, EventArgs e) { string comment = tbxComment.Text; int SenderId = Convert.ToInt32(Session["UserId"]); if (string.Compare(comment, "") != 0) { SqlConnection connect = new SqlConnection(ConfigurationManager.ConnectionStrings["UserDetailsConnectionString"].ConnectionString); string getFields = "insert into tblComments(SenderId,Comment) values(@SenderId,@Comment)"; SqlCommand cmd = new SqlCommand(getFields, connect); connect.Open(); cmd.Parameters.AddWithValue("@SenderId", SenderId); cmd.Parameters.AddWithValue("@Comment", tbxComment.Text); cmd.ExecuteNonQuery(); connect.Close(); tbxComment.Text = ""; } RepeaterComment.DataSource = GetComments("Select c.Id,c.Comment,c.Likes,u.Name,u.Image from tblComments as c inner join tblUsers as u on u.Id=c.SenderId"); RepeaterComment.DataBind(); Response.Redirect("Commenting.aspx"); }