protected void lbInsert_Click(object sender, EventArgs e) { SqlDataSourceUser.InsertParameters["f_name"].DefaultValue = ((TextBox)GridView1.FooterRow.FindControl("txtFName")).Text; SqlDataSourceUser.InsertParameters["l_name"].DefaultValue = ((TextBox)GridView1.FooterRow.FindControl("txtLName")).Text; SqlDataSourceUser.InsertParameters["email"].DefaultValue = ((TextBox)GridView1.FooterRow.FindControl("txtEmail")).Text; SqlDataSourceUser.InsertParameters["password"].DefaultValue = ((TextBox)GridView1.FooterRow.FindControl("txtPass")).Text; SqlDataSourceUser.InsertParameters["last_login"].DefaultValue = "01/ 01/16"; SqlDataSourceUser.Insert(); }
protected void Button1_Click(object sender, EventArgs e) { Msg.Text = ""; Msg.CssClass = ""; DataView dv = SqlDataSourceUser.Select(DataSourceSelectArguments.Empty) as DataView; bool Exists = false; if (dv != null) { for (int i = 0; i < dv.Table.Rows.Count; i++) { if (EmailId.Text == dv.Table.Rows[i]["EmailId"].ToString()) { Exists = true; break; } } } if (Exists) { Msg.Text = "Email already registered"; Msg.CssClass = "text-danger"; } else { string FileName = Photo.FileName.ToLower(); string Extension = FileName.Substring(FileName.LastIndexOf('.')); if (Extension == ".jpg" || Extension == ".jpeg" || Extension == ".png") { HiddenFieldPhoto.Value = "/photos/" + FileName; Photo.SaveAs(Server.MapPath(HiddenFieldPhoto.Value)); SqlDataSourceUser.Insert(); Msg.Text = "Sign Up successful"; Msg.CssClass = "text-success"; } else { Msg.Text = "Please select an image file"; Msg.CssClass = "text-danger"; } } }