Beispiel #1
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        DataView dv = SqlDataSourceAdmin.Select(DataSourceSelectArguments.Empty) as DataView;

        if (dv != null)
        {
            bool exists = false;
            for (int i = 0; i < dv.Table.Rows.Count; i++)
            {
                if (username.Text.ToLower() == dv.Table.Rows[i]["Username"].ToString().ToLower() || emailid.Text == dv.Table.Rows[i]["Emailid"].ToString())
                {
                    exists = true;
                    break;
                }
            }
            if (exists)
            {
                msg.Text     = "Account already exists with Username or Email-id";
                msg.CssClass = "text-danger";
            }
            else
            {
                msg.Text = "";
                SqlDataSourceAdmin.Insert();
                msg.Text     = "Account created successfully!";
                msg.CssClass = "text-success";
            }
            ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "", "$('#myModal').modal('hide');$('body').removeClass('modal-open');$('.modal-backdrop').remove();$('#myModal').modal('show');", true);
        }
    }
Beispiel #2
0
        protected void insertButton_Click1(object sender, EventArgs e)
        {
            SqlDataSourceAdmin.InsertParameters["ID"].DefaultValue        = ((TextBox)GridView1.FooterRow.FindControl("txtID")).Text;
            SqlDataSourceAdmin.InsertParameters["FirstName"].DefaultValue = ((TextBox)GridView1.FooterRow.FindControl("txtFname")).Text;
            SqlDataSourceAdmin.InsertParameters["LastName"].DefaultValue  = ((TextBox)GridView1.FooterRow.FindControl("txtLname")).Text;
            SqlDataSourceAdmin.InsertParameters["Username"].DefaultValue  = ((TextBox)GridView1.FooterRow.FindControl("txtUname")).Text;
            SqlDataSourceAdmin.InsertParameters["Password"].DefaultValue  = ((TextBox)GridView1.FooterRow.FindControl("txtPword")).Text;
            SqlDataSourceAdmin.InsertParameters["Email"].DefaultValue     = ((TextBox)GridView1.FooterRow.FindControl("txtEmail")).Text;
            SqlDataSourceAdmin.InsertParameters["Course"].DefaultValue    = ((TextBox)GridView1.FooterRow.FindControl("txtCourse")).Text;

            SqlDataSourceAdmin.Insert();
        }