tags:

views:

23

answers:

2

I have GridView on my ASP.NET page and I have set OnRowCommand="gdvCar_RowCommand" OnRowDataBound="gdvCar_DataBound" for my grid. In gdvCar_DataBound I add three buttons, but when I click on them it goes to PostBack but doesn't come in gdvCar_RowCommand at all and that buttons disapear. Does anybody have same problem or have idea what is the problem ?

protected void gdvCar_DataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) {

        String id=e.Row.Cells[0].Text;
        Image img = new Image();
        img.Width = 96;
        img.Height = 96;
        img.ImageUrl = "images/car/" + e.Row.Cells[7].Text;
        TableCell tc = new TableCell();
        tc.Controls.Add(img);
        e.Row.Cells.Add(tc);


        ImageButton imbReserve = new ImageButton();
        imbReserve.ID = "res" + id;
        imbReserve.Enabled = true;
        imbReserve.Width = 48; imbReserve.Height = 48;
        imbReserve.ToolTip = "Reserve"; imbReserve.AlternateText = "Reserve";
        imbReserve.ImageUrl = "images/icons/key.gif";
        imbReserve.CommandName = "Reserve";
        imbReserve.CommandArgument = id;
        tc = new TableCell();
        tc.Controls.Add(imbReserve);
        e.Row.Cells.Add(tc);

        ImageButton imbPhone = new ImageButton();
        imbPhone.ID= "phone" + id;
        imbPhone.Enabled = true;
        imbPhone.Width = 48; imbPhone.Height = 48;
        imbPhone.ToolTip = "Reserve by phone"; imbPhone.AlternateText = "Phone";
        imbPhone.ImageUrl = "images/icons/phone.jpg";
        imbPhone.CommandName = "Phone";
        imbPhone.CommandArgument = id;
        tc = new TableCell();
        tc.Controls.Add(imbPhone);
        e.Row.Cells.Add(tc);

        ImageButton imbEmail = new ImageButton();
        imbEmail.ID = "email" + id;
        imbEmail.Enabled = true;
        imbEmail.Width = 48; imbEmail.Height = 48;
        imbEmail.ToolTip = "Reserve by email"; imbEmail.AlternateText = "Email";
        imbEmail.ImageUrl = "images/icons/email.jpg";
        imbEmail.CommandName = "Email";
        imbEmail.CommandArgument = id;
        tc = new TableCell();
        tc.Controls.Add(imbEmail);
        e.Row.Cells.Add(tc);





    }
}
A: 

Question is not clear , send ur source for me to find out whats wrong with ur code [email protected]

arlen
Sent on email !
Rebecca
A: 

I coulden't send the answer for you through stackoverflow.com , so I emailed you.

arlen