Add the image and path to the database for the specific users

protected void Upload(object sender, EventArgs e) { //Extract Image File Name. string fileName = Path.GetFileName(FileUpload1.PostedFile.FileName); //Set the Image File Path. string filePath = "~/Uploads/" + fileName; //Save the Image File in Folder. FileUpload1.PostedFile.SaveAs(Server.MapPath(filePath)); string mycon = "server =localhost; Uid=root; password = ; persistsecurityinfo = True; database =ovs; SslMode = none"; MySqlConnection con1 = new MySqlConnection(mycon); … Read more

The users input can’t save to database

<ItemTemplate> <asp:Label ID="lbldescription" runat="server" width="175px" Text='<%#Eval("description") %>'/> </ItemTemplate> <EditItemTemplate> <asp:TextBox ID="txtdescription" runat="server"></asp:TextBox> </EditItemTemplate> protected void gvManage_RowUpdating(object sender, GridViewUpdateEventArgs e) { string topicID = gvtopic.DataKeys[e.RowIndex].Values["topicID"].ToString(); TextBox description = (TextBox)gvtopic.Rows[e.RowIndex].FindControl("txtdescription"); string sql = "Update topic SET <a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="f692938595849f86829f9998cbb692938595849f86829f9998">[email protected]</a> WHERE topicID= @topicID"; var cmd = new MySqlCommand(sql, con); con.Open(); cmd.Parameters.AddWithValue("@topicID",topicID); cmd.Parameters.AddWithValue("@description", description); cmd.ExecuteNonQuery(); con.Close(); gvtopic.EditIndex = … Read more

Find the value in gridview using findcontrol and comapre it with data in database

protected void LinkButton_Click(Object sender, EventArgs e) { String MyConnection2 = "Server=localhost;database=ovs;Uid=root;password=; Convert Zero Datetime=True"; DateTime time = DateTime.Now; // Use current time string format = "yyyy-MM-dd HH:mm:ss"; string UserName4 = HttpContext.Current.User.Identity.Name; GridViewRow grdrow = (GridViewRow)((LinkButton)sender).NamingContainer; Label lblStudentId = (Label)grdrow.Cells[0].FindControl("lblID"); string studentId = lblStudentId.Text; String query = "insert into voting (CandidateStudentID,voterStudentID,DateTime)values ('" + lblStudentId.Text + "','" … Read more