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="tr ue"
OnModeChanging="DV_Company _ModeChang ing"
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_Extrac t("SP_Sele ct_HotelDe tails_From _HotelID", Session["HotelierID"], "EHotelId");
DV_Company.DataSource = DSView;
DV_Company.DataBind();
}
protected void DV_Company_ModeChanging(ob ject sender, DetailsViewModeEventArgs e)
{
DV_Company.DefaultMode = DetailsViewMode.Edit;
}
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="tr
OnModeChanging="DV_Company
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
{
if (!Page.IsPostBack)
{
BindDV();
}
}
}
private void BindDV()
{
DataSet DSView = new DataSet();
DSView = Globalfn.DataSource_Extrac
DV_Company.DataSource = DSView;
DV_Company.DataBind();
}
protected void DV_Company_ModeChanging(ob
{
DV_Company.DefaultMode = DetailsViewMode.Edit;
}
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 .
"Check the DetailsView's ItemUpdating event" - I want to know how to capture the edit click event .
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
anyone know how to do this?
Did you try the code in my post above?
Forced accept.
Computer101
EE Admin
Computer101
EE Admin
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