Archive
Calender
<<  February 2012  >>
MoTuWeThFrSaSu
303112345
6789101112
13141516171819
20212223242526
2728291234
567891011
Blogroll
    Recent comments

    None

     

    Click on the login control and click the events lightning button. Double click on the LoggedIn event.

     

    protected void Login1_LoggedIn(object sender, EventArgs e)
    
            {
    
                if (Roles.IsUserInRole(this.Login1.UserName, "administrator"))
    
                {
    
                    this.Login1.DestinationPageUrl = "~/admin/default.aspx";
    
                }
    
                else if (Roles.IsUserInRole(this.Login1.UserName, "member"))
    
                {
    
                    this.Login1.DestinationPageUrl = "~/member/default.aspx";
    
                }
    
                Response.Redirect(ResolveClientUrl(Login1.DestinationPageUrl));
    
            }

     

     

     

     

    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    
            {
    
                if ((string)e.CommandName == "Select")
    
                {
    
                    int index = Convert.ToInt32(e.CommandArgument);
    
                    int itemID = Convert.ToInt32(this.GridView1.DataKeys[index].Value);
    
                    string urlRedirect = string.Format("~/yourpage.aspx?ID={0}", itemID);
    
                    Response.Redirect(urlRedirect);
    
                }
    
            }

     

     

     

    Drag a fileUpload control onto your web form.

    Drag the sql  image tab le onto your web form to create the SqlDataSource1 control.

    Click on the SqlDataSource1 object, right click and select properties. On the properties

    Window, click the lightning bolt button at the top to access the available SqlDataSource1 events. Double click on the inserting event.

    in the code behind file, validate the FileUpload1 control...

    if (!this.FileUpload1.HasFile) {

    ErrorLabel.Text = "Select the picture file.";

    return; file

    }  

    protected void SqlDataSource1 _Inserting(object sender, SqlDataSourceCommandEventArgs e)

            {

                byte[] newPicture = FileUpload1.FileBytes;

                   e.Command.Parameters.Clear();

    System.Data.SqlClient.SqlParameter  pictureParam = new System.Data.SqlClient.SqlParameter("@picture", System.Data.SqlDbType.Image);

                pictureParam.Value = newPicture;

                e.Command.Parameters.Add(pictureParam);

            }