jeudi 28 mai 2015

Detailsview templatefield mapping to ObjectDataSource?

I need help to understand the proper way to map or associate TemplateFields to the ObjectDataSource. I show only one (of many) template definitions here:

    <asp:TemplateField HeaderText="First Name" SortExpression="cFIRSTNAME">
    <ItemTemplate>
        <asp:Label ID="lblValFirstName" runat="server" Text='<%# Eval("cFIRSTNAME") %>' style="font-weight: bold;" ></asp:Label>
    </ItemTemplate>
    <EditItemTemplate>
        <asp:TextBox ID="txtFirstName" runat="server" Text='<%# Bind("cFIRSTNAME") %>' MaxLength="20"></asp:TextBox>
    </EditItemTemplate>
    <InsertItemTemplate>
        <asp:TextBox ID="txtFirstName" runat="server" Text='<%# Bind("cFIRSTNAME") %>' MaxLength="20"></asp:TextBox>
    </InsertItemTemplate>
   </asp:TemplateField>

The ObjectDataSource and update parameters are:

    <asp:ObjectDataSource ID="ODS_LOGIN_DETAILS" runat="server" 
    SelectMethod="GetLOGINSbyLoginID" 
    TypeName="bllLOGINS" 
    DeleteMethod="DeleteFromDetailsView" 
    InsertMethod="InsertFromDetailsView" 
    UpdateMethod="UpdateFromDetailsView" OldValuesParameterFormatString="original_{0}"> <UpdateParameters>
  <asp:Parameter Name="p_UID_LOGIN" Type="Int32" />
  <asp:Parameter Name="p_UID_CONTACT" Type="Int32" />
  <asp:Parameter Name="p_UID_USER_TYPE" Type="Int32" />
  <asp:Parameter Name="p_TXT_USERNAME" Type="String" />
  <asp:Parameter Name="p_TXT_PASSWORD" Type="String" />
  <asp:Parameter Name="p_BOOL_IS_ACTIVE" Type="Boolean" />
  <asp:Parameter Name="p_DT_END" Type="DateTime" />
  <asp:Parameter Name="p_FirstName" Type="String" />
  <asp:Parameter Name="p_LastName" Type="String" />
  <asp:Parameter Name="p_CONTACTTITLE" Type="String" />
  <asp:Parameter Name="p_TXT_PHONE" Type="String" />
  <asp:Parameter Name="p_CONTACT_EMAIL" Type="String" /> </UpdateParameters>

What is NOT clear to me is how is the mapping made from the templatefield textbox (txtFirstName) to the UpdateParameter "p_FirstName"?

In the existing code I am working with, I see the ObjectDataSource_Updating()-event that does a series of DVW.FindControl() values being assigned/set to the

e.InputParameter("param-name") = text-box-value

Questions?

Is this done in either the ObjectDataSource_Updating()-event or in the DetailsView_Updtaing()-event -or- by declaration aspx code?

or how?

What is the best way to do this?

Would naming the textbox-ID and the parameter-name simplify the code?

I am assuming the solutions offered would be "similar" or the same as with SqlDataSource -- please confirm?

Thanks in advance...John




Aucun commentaire:

Enregistrer un commentaire