Link to home
Start Free TrialLog in
Avatar of sainisherry
sainisherry

asked on

DetailsView Control Edit with code behind

Hello everyone

ASP.NET 2.0
C#.NET

I have a DetailsView Control and it is bind to the db from the code behind. And now i want to edit the detailsview and submit the changes from code behind only. When i click Edit link on the bottom, the detailsView doesn't get changed into Textfields for each boundField ? I am new to this control. And i dont know to capture the edit click event from the code behind? I dont understand where i am getting wrong. Please give ur help. Please fill up the gaps in the below code.

Code:- ASPX page
########################################
<asp:DetailsView ID="DV_Company" runat="server"
                                     AutoGenerateRows="False" DataKeyNames="Hotelier_id"
                                    CellPadding="4" ForeColor="#333333" GridLines="None"
                                     AutoGenerateEditButton="true"
                                      OnModeChanging="DV_Company_ModeChanging"                          
                                    Width="90%" CellSpacing="5">
                                        <Fields>                                        
                                        <asp:BoundField HeaderText="Company" DataField="company_name" />
                                        <asp:BoundField HeaderText="Address" DataField="Address_details" />
                                        <asp:BoundField HeaderText="Contact Person" DataField="Contact_Person" />
                                        <asp:BoundField HeaderText="Phone1" DataField="Phone2" />
                                        <asp:BoundField HeaderText="Mobile" DataField="mobile_number" />
                                        <asp:BoundField HeaderText="FAX" DataField="fax_number" />
                                        <asp:BoundField HeaderText="Email" DataField="email_id" />
                                       
                                        </Fields>                                  
                                     
                                    </asp:DetailsView>
                                   
########################################

ASPX.CS code behind code.


 protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["Session_UserName"] != null)
        {
            if (!Page.IsPostBack)
            {
                BindDV();
            }
        }
    }
    private void BindDV()
    {
        DataSet DSView = new DataSet();
        DSView = Globalfn.DataSource_Extract("SP_Select_HotelDetails_From_HotelID", Session["HotelierID"], "EHotelId");

        DV_Company.DataSource = DSView;
        DV_Company.DataBind();
    }

    protected void DV_Company_ModeChanging(object sender, DetailsViewModeEventArgs e)
    {
        DV_Company.DefaultMode = DetailsViewMode.Edit;
    }

Avatar of DarkoLord
DarkoLord
Flag of Slovenia image

> When i click Edit link on the bottom, the detailsView doesn't get changed into Textfields for each boundField ?

What do you get instead?

> And i dont know to capture the edit click event from the code behind?

Check the DetailsView's ItemUpdating event
Avatar of sainisherry
sainisherry

ASKER

it opens the page with no change. The detailsview bounditems are still in the view mode rather than edit mode...

"Check the DetailsView's ItemUpdating event" - I want to know how to capture the edit click event .
ASKER CERTIFIED SOLUTION
Avatar of DarkoLord
DarkoLord
Flag of Slovenia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
anyone know how to do this?
Did you try the code in my post above?
Forced accept.

Computer101
EE Admin