在c#、Visual Studio 2010中显示来自另一个表的数据(数据绑定?)

本文关键字:另一个 数据 数据绑定 Visual Studio 2010 显示 | 更新日期: 2023-09-27 18:07:06

我有以下问题:我有2个表:

1)表1:STRANKA (ID_STRANKE(主键),IME, primek, TELEFON, NASLOV, POSTA)2)表2:VOZILO (REG_STEVILKA(主键),ID_STRANKE, ZNAMKA, MODEL, LETO_IZDELAVE, PROSTORNINA_MOTORJA, MOC_MOTORJA, TIP_MOTORJA, VIN_STEVILKA)

"STRANKA"的每个成员可以有0:n个"VOZILO"的成员,而"VOZILO"的每个成员恰好有1个来自"STRANKA"的成员。

现在,我有DetailsView (DetailsView2是代码中的实际名称),它显示来自"VOZILO"的某个成员的所有列。现在-我想做的是将列"ID_STRANKE"替换为"IME + primek"。要做到这一点,我必须以某种方式将这两个表连接起来。我真的不知道该怎么做。有人能帮忙吗?谢谢!

<%@ Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="Vozila.aspx.cs" Inherits="CernaticJurij_Default2" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" Runat="Server">
    </asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">
    <h3>ISKANJE PODATKOV VOZIL</h3>
    <p>Za prikaz podatkov vozila lahko neposredno vnesete registrsko številko vozila, 
        lahko pa najprej poiščete stranko ter izberete željeno vozilo.</p>
    <br />
    Registrska številka vozila oziroma ime ali priimek stranke:<br />
    <br />
    <asp:TextBox ID="okno_iskanje_strank" runat="server"></asp:TextBox>
    &nbsp;&nbsp;
    <asp:Button ID="iskanje_stranke" runat="server" Height="25px" 
        style="margin-top: 0px" Text="Iskanje" Width="70px" />
    <br />
    <br />
    <br />
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
    DataKeyNames="ID_STRANKE" DataSourceID="SQL_STRANKE" Height="16px" 
        Width="881px" AllowPaging="True" CellPadding="4" ForeColor="#333333" 
        GridLines="None">
        <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
    <Columns>
        <asp:CommandField 
            ShowSelectButton="True" SelectText="Izberi" />
        <asp:BoundField DataField="ID_STRANKE" HeaderText="ID STRANKE" ReadOnly="True" 
            SortExpression="ID_STRANKE" />
        <asp:BoundField DataField="IME" HeaderText="IME" SortExpression="IME" />
        <asp:BoundField DataField="PRIIMEK" HeaderText="PRIIMEK" 
            SortExpression="PRIIMEK" />
        <asp:BoundField DataField="TELEFON" HeaderText="TELEFON" 
            SortExpression="TELEFON" />
        <asp:BoundField DataField="NASLOV" HeaderText="NASLOV" 
            SortExpression="NASLOV" />
        <asp:BoundField DataField="POSTA" HeaderText="POŠTA" SortExpression="POSTA" />
    </Columns>
        <EditRowStyle BackColor="#999999" />
        <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
        <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
        <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
        <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
        <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
        <SortedAscendingCellStyle BackColor="#E9E7E2" />
        <SortedAscendingHeaderStyle BackColor="#506C8C" />
        <SortedDescendingCellStyle BackColor="#FFFDF8" />
        <SortedDescendingHeaderStyle BackColor="#6F8DAE" />
</asp:GridView>
<asp:SqlDataSource ID="SQL_STRANKE" runat="server" 
    ConnectionString="<%$ ConnectionStrings:Stranke %>" 

        SelectCommand="SELECT * FROM [STRANKA] WHERE ([PRIIMEK] LIKE @PRIIMEK+'%') OR ([IME] LIKE @PRIIMEK+'%')" 
        DeleteCommand="DELETE FROM [STRANKA] WHERE [ID_STRANKE] = @ID_STRANKE" 
        InsertCommand="INSERT INTO [STRANKA] ([ID_STRANKE], [IME], [PRIIMEK], [TELEFON], [NASLOV], [POSTA]) VALUES (@ID_STRANKE, @IME, @PRIIMEK, @TELEFON, @NASLOV, @POSTA)" 
        UpdateCommand="UPDATE [STRANKA] SET [IME] = @IME, [PRIIMEK] = @PRIIMEK, [TELEFON] = @TELEFON, [NASLOV] = @NASLOV, [POSTA] = @POSTA WHERE [ID_STRANKE] = @ID_STRANKE">
    <DeleteParameters>
        <asp:Parameter Name="ID_STRANKE" Type="String" />
    </DeleteParameters>
    <InsertParameters>
        <asp:Parameter Name="ID_STRANKE" Type="String" />
        <asp:Parameter Name="IME" Type="String" />
        <asp:Parameter Name="PRIIMEK" Type="String" />
        <asp:Parameter Name="TELEFON" Type="String" />
        <asp:Parameter Name="NASLOV" Type="String" />
        <asp:Parameter Name="POSTA" Type="String" />
    </InsertParameters>
    <SelectParameters>
        <asp:ControlParameter ControlID="okno_iskanje_strank" Name="PRIIMEK" 
            PropertyName="Text" Type="String" />
    </SelectParameters>
    <UpdateParameters>
        <asp:Parameter Name="IME" Type="String" />
        <asp:Parameter Name="PRIIMEK" Type="String" />
        <asp:Parameter Name="TELEFON" Type="String" />
        <asp:Parameter Name="NASLOV" Type="String" />
        <asp:Parameter Name="POSTA" Type="String" />
        <asp:Parameter Name="ID_STRANKE" Type="String" />
    </UpdateParameters>
</asp:SqlDataSource>
    <asp:DetailsView ID="DetailsView2" runat="server" AutoGenerateRows="False" 
        CellPadding="4" DataKeyNames="REG_STEVILKA" DataSourceID="SqlDataSource4" 
        ForeColor="#333333" GridLines="None" Height="50px" Width="300px">
        <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
        <CommandRowStyle BackColor="#E2DED6" Font-Bold="True" />
        <EditRowStyle BackColor="#999999" />
        <FieldHeaderStyle BackColor="#E9ECF1" Font-Bold="True" />
        <Fields>
            <asp:BoundField DataField="REG_STEVILKA" HeaderText="REGISTRSKA ŠTEVILKA" 
                ReadOnly="True" SortExpression="REG_STEVILKA" />
            <asp:BoundField DataField="ID_STRANKE" HeaderText="ID_STRANKE" 
                SortExpression="ID_STRANKE" />
            <asp:BoundField DataField="ZNAMKA" HeaderText="ZNAMKA" 
                SortExpression="ZNAMKA" />
            <asp:BoundField DataField="MODEL" HeaderText="MODEL" SortExpression="MODEL" />
            <asp:BoundField DataField="LETO_IZDELAVE" HeaderText="LETO IZDELAVE" 
                SortExpression="LETO_IZDELAVE" />
            <asp:BoundField DataField="PROSTORNINA_MOTORJA" 
                HeaderText="PROSTORNINA MOTORJA" SortExpression="PROSTORNINA_MOTORJA" />
            <asp:BoundField DataField="MOC_MOTORJA" HeaderText="MOČ MOTORJA" 
                SortExpression="MOC_MOTORJA" />
            <asp:BoundField DataField="TIP_MOTORJA" HeaderText="TIP MOTORJA" 
                SortExpression="TIP_MOTORJA" />
            <asp:BoundField DataField="VIN_STEVILKA" HeaderText="VIN ŠTEVILKA" 
                SortExpression="VIN_STEVILKA" />
            <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" 
                CancelText="Prekliči" DeleteText="Izbriši" EditText="Uredi" 
                UpdateText="Shrani" />
        </Fields>
        <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
        <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
        <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
        <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
    </asp:DetailsView>
    <br />
    <asp:GridView ID="GridView2" runat="server" AllowPaging="True" 
        AutoGenerateColumns="False" DataKeyNames="REG_STEVILKA" 
        DataSourceID="SqlDataSource2" CellPadding="4" ForeColor="#333333" 
        GridLines="None" Width="400px">
        <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
        <Columns>
            <asp:CommandField ShowDeleteButton="False" ShowEditButton="False" 
                ShowSelectButton="True" CancelText="Prekliči" DeleteText="Izbriši" 
                EditText="Uredi" InsertText="Shrani" NewText="Dodaj " SelectText="Izberi" 
                UpdateText="Shrani" />
            <asp:BoundField DataField="REG_STEVILKA" HeaderText="REGISTRSKA ŠTEVILKA" 
                ReadOnly="True" SortExpression="REG_STEVILKA" />
            <asp:BoundField DataField="ZNAMKA" HeaderText="ZNAMKA" 
                SortExpression="ZNAMKA" />
            <asp:BoundField DataField="MODEL" HeaderText="MODEL" SortExpression="MODEL" />
        </Columns>
        <EditRowStyle BackColor="#999999" />
        <EmptyDataTemplate>
        </EmptyDataTemplate>
        <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
        <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
        <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
        <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
        <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
        <SortedAscendingCellStyle BackColor="#E9E7E2" />
        <SortedAscendingHeaderStyle BackColor="#506C8C" />
        <SortedDescendingCellStyle BackColor="#FFFDF8" />
        <SortedDescendingHeaderStyle BackColor="#6F8DAE" />
    </asp:GridView>
    <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
        ConnectionString="<%$ ConnectionStrings:Stranke %>" 
        DeleteCommand="DELETE FROM [VOZILO] WHERE [REG_STEVILKA] = @REG_STEVILKA" 
        InsertCommand="INSERT INTO [VOZILO] ([REG_STEVILKA], [ZNAMKA], [MODEL]) VALUES (@REG_STEVILKA, @ZNAMKA, @MODEL)" 
        SelectCommand="SELECT [REG_STEVILKA], [ZNAMKA], [MODEL] FROM [VOZILO] WHERE ([ID_STRANKE] = @ID_STRANKE)" 
        UpdateCommand="UPDATE [VOZILO] SET [ZNAMKA] = @ZNAMKA, [MODEL] = @MODEL WHERE [REG_STEVILKA] = @REG_STEVILKA">
        <DeleteParameters>
            <asp:Parameter Name="REG_STEVILKA" Type="String" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="REG_STEVILKA" Type="String" />
            <asp:Parameter Name="ZNAMKA" Type="String" />
            <asp:Parameter Name="MODEL" Type="String" />
        </InsertParameters>
        <SelectParameters>
            <asp:ControlParameter ControlID="GridView1" Name="ID_STRANKE" 
                PropertyName="SelectedValue" Type="String" />
        </SelectParameters>
        <UpdateParameters>
            <asp:Parameter Name="ZNAMKA" Type="String" />
            <asp:Parameter Name="MODEL" Type="String" />
            <asp:Parameter Name="REG_STEVILKA" Type="String" />
        </UpdateParameters>
    </asp:SqlDataSource>
    <br />
    <br />
    <br />
    <asp:DetailsView ID="DetailsView1" runat="server" AllowPaging="True" 
        AutoGenerateRows="False" CellPadding="4" DataKeyNames="REG_STEVILKA" 
        DataSourceID="SqlDataSource3" ForeColor="#333333" GridLines="None" 
        Height="50px" Width="300px">
        <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
        <CommandRowStyle BackColor="#E2DED6" Font-Bold="True" />
        <EditRowStyle BackColor="#999999" />
        <EmptyDataTemplate>
            <asp:LinkButton ID="NovoPrazno" runat="server" CausesValidation="False" 
                CommandName="New" Text="Vnos novega vozila" />
        </EmptyDataTemplate>
        <FieldHeaderStyle BackColor="#E9ECF1" Font-Bold="True" />
        <Fields>
            <asp:BoundField DataField="REG_STEVILKA" HeaderText="REGISTRSKA ŠTEVILKA" 
                ReadOnly="True" SortExpression="REG_STEVILKA" />
            <asp:BoundField DataField="ZNAMKA" HeaderText="ZNAMKA" 
                SortExpression="ZNAMKA" />
            <asp:BoundField DataField="MODEL" 
                HeaderText="MODEL" SortExpression="MODEL" />
            <asp:BoundField DataField="LETO_IZDELAVE" HeaderText="LETO IZDELAVE" 
                SortExpression="LETO_IZDELAVE" />
            <asp:BoundField DataField="PROSTORNINA_MOTORJA" HeaderText="PROSTORNINA MOTORJA" 
                SortExpression="PROSTORNINA_MOTORJA" />
            <asp:BoundField DataField="MOC_MOTORJA" HeaderText="MOČ MOTORJA" 
                SortExpression="MOC_MOTORJA" />
            <asp:BoundField DataField="TIP_MOTORJA" HeaderText="TIP MOTORJA" 
                SortExpression="TIP_MOTORJA" />
            <asp:BoundField DataField="VIN_STEVILKA" HeaderText="VIN ŠTEVILKA" 
                SortExpression="VIN_STEVILKA" />
            <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" 
                ShowInsertButton="True" CancelText="Prekliči" DeleteText="Izbriši" 
                EditText="Uredi" InsertText="Shrani" NewText="Dodaj novo vozilo" 
                UpdateText="Shrani" />
        </Fields>
        <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
        <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
        <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
        <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
    </asp:DetailsView>
    <asp:SqlDataSource ID="SqlDataSource3" runat="server" 
        ConnectionString="<%$ ConnectionStrings:Stranke %>" 

        SelectCommand="SELECT * FROM [VOZILO] WHERE (([REG_STEVILKA] = @REG_STEVILKA))" 
        DeleteCommand="DELETE FROM [VOZILO] WHERE [REG_STEVILKA] = @REG_STEVILKA" 
        InsertCommand="INSERT INTO [VOZILO] ([REG_STEVILKA], [ID_STRANKE], [ZNAMKA], [MODEL], [LETO_IZDELAVE], [PROSTORNINA_MOTORJA], [MOC_MOTORJA], [TIP_MOTORJA], [VIN_STEVILKA]) VALUES (@REG_STEVILKA, @ID_STRANKE, @ZNAMKA, @MODEL, @LETO_IZDELAVE, @PROSTORNINA_MOTORJA, @MOC_MOTORJA, @TIP_MOTORJA, @VIN_STEVILKA)" 

        UpdateCommand="UPDATE [VOZILO] SET [ZNAMKA] = @ZNAMKA, [MODEL] = @MODEL, [LETO_IZDELAVE] = @LETO_IZDELAVE, [PROSTORNINA_MOTORJA] = @PROSTORNINA_MOTORJA, [MOC_MOTORJA] = @MOC_MOTORJA, [TIP_MOTORJA] = @TIP_MOTORJA, [VIN_STEVILKA] = @VIN_STEVILKA WHERE [REG_STEVILKA] = @REG_STEVILKA">
        <DeleteParameters>
            <asp:Parameter Name="REG_STEVILKA" Type="String" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="REG_STEVILKA" Type="String" />
            <asp:ControlParameter ControlID="GridView1" Name="ID_STRANKE" 
                PropertyName="SelectedValue" Type="String" />
            <asp:Parameter Name="ZNAMKA" Type="String" />
            <asp:Parameter Name="MODEL" Type="String" />
            <asp:Parameter Name="LETO_IZDELAVE" Type="String" />
            <asp:Parameter Name="PROSTORNINA_MOTORJA" Type="String" />
            <asp:Parameter Name="MOC_MOTORJA" Type="String" />
            <asp:Parameter Name="TIP_MOTORJA" Type="String" />
            <asp:Parameter Name="VIN_STEVILKA" Type="String" />
        </InsertParameters>
        <SelectParameters>
            <asp:ControlParameter ControlID="GridView2" Name="REG_STEVILKA" 
                PropertyName="SelectedValue" Type="String" />
        </SelectParameters>
        <UpdateParameters>
            <asp:Parameter Name="ZNAMKA" Type="String" />
            <asp:Parameter Name="MODEL" Type="String" />
            <asp:Parameter Name="LETO_IZDELAVE" Type="String" />
            <asp:Parameter Name="PROSTORNINA_MOTORJA" Type="String" />
            <asp:Parameter Name="MOC_MOTORJA" Type="String" />
            <asp:Parameter Name="TIP_MOTORJA" Type="String" />
            <asp:Parameter Name="VIN_STEVILKA" Type="String" />
            <asp:Parameter Name="REG_STEVILKA" Type="String" />
        </UpdateParameters>
    </asp:SqlDataSource>
    <br />
    <asp:SqlDataSource ID="SqlDataSource4" runat="server" 
        ConnectionString="<%$ ConnectionStrings:Stranke %>" 
        DeleteCommand="DELETE FROM [VOZILO] WHERE [REG_STEVILKA] = @REG_STEVILKA" 
        InsertCommand="INSERT INTO [VOZILO] ([REG_STEVILKA], [ID_STRANKE], [ZNAMKA], [MODEL], [LETO_IZDELAVE], [PROSTORNINA_MOTORJA], [MOC_MOTORJA], [TIP_MOTORJA], [VIN_STEVILKA]) VALUES (@REG_STEVILKA, @ID_STRANKE, @ZNAMKA, @MODEL, @LETO_IZDELAVE, @PROSTORNINA_MOTORJA, @MOC_MOTORJA, @TIP_MOTORJA, @VIN_STEVILKA)" 
        SelectCommand="SELECT * FROM [VOZILO] WHERE ([REG_STEVILKA] = @REG_STEVILKA)" 
        UpdateCommand="UPDATE [VOZILO] SET [ID_STRANKE] = @ID_STRANKE, [ZNAMKA] = @ZNAMKA, [MODEL] = @MODEL, [LETO_IZDELAVE] = @LETO_IZDELAVE, [PROSTORNINA_MOTORJA] = @PROSTORNINA_MOTORJA, [MOC_MOTORJA] = @MOC_MOTORJA, [TIP_MOTORJA] = @TIP_MOTORJA, [VIN_STEVILKA] = @VIN_STEVILKA WHERE [REG_STEVILKA] = @REG_STEVILKA">
        <DeleteParameters>
            <asp:Parameter Name="REG_STEVILKA" Type="String" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="REG_STEVILKA" Type="String" />
            <asp:Parameter Name="ID_STRANKE" Type="String" />
            <asp:Parameter Name="ZNAMKA" Type="String" />
            <asp:Parameter Name="MODEL" Type="String" />
            <asp:Parameter Name="LETO_IZDELAVE" Type="String" />
            <asp:Parameter Name="PROSTORNINA_MOTORJA" Type="String" />
            <asp:Parameter Name="MOC_MOTORJA" Type="String" />
            <asp:Parameter Name="TIP_MOTORJA" Type="String" />
            <asp:Parameter Name="VIN_STEVILKA" Type="String" />
        </InsertParameters>
        <SelectParameters>
            <asp:ControlParameter ControlID="okno_iskanje_strank" Name="REG_STEVILKA" 
                PropertyName="Text" Type="String" />
        </SelectParameters>
        <UpdateParameters>
            <asp:Parameter Name="ID_STRANKE" Type="String" />
            <asp:Parameter Name="ZNAMKA" Type="String" />
            <asp:Parameter Name="MODEL" Type="String" />
            <asp:Parameter Name="LETO_IZDELAVE" Type="String" />
            <asp:Parameter Name="PROSTORNINA_MOTORJA" Type="String" />
            <asp:Parameter Name="MOC_MOTORJA" Type="String" />
            <asp:Parameter Name="TIP_MOTORJA" Type="String" />
            <asp:Parameter Name="VIN_STEVILKA" Type="String" />
            <asp:Parameter Name="REG_STEVILKA" Type="String" />
        </UpdateParameters>
    </asp:SqlDataSource>
</asp:Content>

在c#、Visual Studio 2010中显示来自另一个表的数据(数据绑定?)

您需要连接您的2个数据表。我已经将STRANKE的两列合并为一列,并将STRANKE_ID添加为数据键,您可以分别返回它们并使用模板字段:

<asp:DetailsView ID="DetailsView2" runat="server" AutoGenerateRows="False" 
    CellPadding="4" DataKeyNames="REG_STEVILKA,ID_STRANKE" DataSourceID="SqlDataSource4" 
    ForeColor="#333333" GridLines="None" Height="50px" Width="300px">
    <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
    <CommandRowStyle BackColor="#E2DED6" Font-Bold="True" />
    <EditRowStyle BackColor="#999999" />
    <FieldHeaderStyle BackColor="#E9ECF1" Font-Bold="True" />
    <Fields>
        <asp:BoundField DataField="REG_STEVILKA" HeaderText="REGISTRSKA ŠTEVILKA" 
            ReadOnly="True" SortExpression="REG_STEVILKA" />
        <asp:BoundField DataField="COMPOSITE" HeaderText="ID_STRANKE" 
            SortExpression="COMPOSITE" />
        <asp:BoundField DataField="ZNAMKA" HeaderText="ZNAMKA" 
            SortExpression="ZNAMKA" />
        <asp:BoundField DataField="MODEL" HeaderText="MODEL" SortExpression="MODEL" />
        <asp:BoundField DataField="LETO_IZDELAVE" HeaderText="LETO IZDELAVE" 
            SortExpression="LETO_IZDELAVE" />
        <asp:BoundField DataField="PROSTORNINA_MOTORJA" 
            HeaderText="PROSTORNINA MOTORJA" SortExpression="PROSTORNINA_MOTORJA" />
        <asp:BoundField DataField="MOC_MOTORJA" HeaderText="MOČ MOTORJA" 
            SortExpression="MOC_MOTORJA" />
        <asp:BoundField DataField="TIP_MOTORJA" HeaderText="TIP MOTORJA" 
            SortExpression="TIP_MOTORJA" />
        <asp:BoundField DataField="VIN_STEVILKA" HeaderText="VIN ŠTEVILKA" 
            SortExpression="VIN_STEVILKA" />
        <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" 
            CancelText="Prekliči" DeleteText="Izbriši" EditText="Uredi" 
            UpdateText="Shrani" />
    </Fields>
    <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
    <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
    <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
    <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
</asp:DetailsView>
<asp:SqlDataSource ID="SqlDataSource4" runat="server" 
    ConnectionString="<%$ ConnectionStrings:Stranke %>" 
    DeleteCommand="DELETE FROM [VOZILO] WHERE [REG_STEVILKA] = @REG_STEVILKA" 
    InsertCommand="INSERT INTO [VOZILO] ([REG_STEVILKA], [ID_STRANKE], [ZNAMKA], [MODEL], [LETO_IZDELAVE], [PROSTORNINA_MOTORJA], [MOC_MOTORJA], [TIP_MOTORJA], [VIN_STEVILKA]) VALUES (@REG_STEVILKA, @ID_STRANKE, @ZNAMKA, @MODEL, @LETO_IZDELAVE, @PROSTORNINA_MOTORJA, @MOC_MOTORJA, @TIP_MOTORJA, @VIN_STEVILKA)" 
    SelectCommand="SELECT VOZILO.*, IME + ' ' + PRIIMEK as COMPOSITE FROM [VOZILO] inner join [STRANKA] on VOZILO.ID_STRANKE = STRANKE.ID_STRANKE WHERE ([REG_STEVILKA] = @REG_STEVILKA)" 
    UpdateCommand="UPDATE [VOZILO] SET [ID_STRANKE] = @ID_STRANKE, [ZNAMKA] = @ZNAMKA, [MODEL] = @MODEL, [LETO_IZDELAVE] = @LETO_IZDELAVE, [PROSTORNINA_MOTORJA] = @PROSTORNINA_MOTORJA, [MOC_MOTORJA] = @MOC_MOTORJA, [TIP_MOTORJA] = @TIP_MOTORJA, [VIN_STEVILKA] = @VIN_STEVILKA WHERE [REG_STEVILKA] = @REG_STEVILKA">
    <DeleteParameters>
        <asp:Parameter Name="REG_STEVILKA" Type="String" />
    </DeleteParameters>
    <InsertParameters>
        <asp:Parameter Name="REG_STEVILKA" Type="String" />
        <asp:Parameter Name="ID_STRANKE" Type="String" />
        <asp:Parameter Name="ZNAMKA" Type="String" />
        <asp:Parameter Name="MODEL" Type="String" />
        <asp:Parameter Name="LETO_IZDELAVE" Type="String" />
        <asp:Parameter Name="PROSTORNINA_MOTORJA" Type="String" />
        <asp:Parameter Name="MOC_MOTORJA" Type="String" />
        <asp:Parameter Name="TIP_MOTORJA" Type="String" />
        <asp:Parameter Name="VIN_STEVILKA" Type="String" />
    </InsertParameters>
    <SelectParameters>
        <asp:ControlParameter ControlID="okno_iskanje_strank" Name="REG_STEVILKA" 
            PropertyName="Text" Type="String" />
    </SelectParameters>
    <UpdateParameters>
        <asp:Parameter Name="ID_STRANKE" Type="String" />
        <asp:Parameter Name="ZNAMKA" Type="String" />
        <asp:Parameter Name="MODEL" Type="String" />
        <asp:Parameter Name="LETO_IZDELAVE" Type="String" />
        <asp:Parameter Name="PROSTORNINA_MOTORJA" Type="String" />
        <asp:Parameter Name="MOC_MOTORJA" Type="String" />
        <asp:Parameter Name="TIP_MOTORJA" Type="String" />
        <asp:Parameter Name="VIN_STEVILKA" Type="String" />
        <asp:Parameter Name="REG_STEVILKA" Type="String" />
    </UpdateParameters>
</asp:SqlDataSource>

顺便说一句,下次只提供需要的信息。很难在所有代码

中找到相关的详细信息视图和SQLDataSource