I am working with DevExpress Asp.Net Controls, In GridView EditTempalte have to add checkbox, have to bind checkbox check and uncheck with database column property and on new item insert default unchecked.
here my code.
<dx:ASPxGridView ID="ASPxGridView3" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource3"
KeyFieldName="UniqueID" Theme="Default">
<SettingsSearchPanel Visible="True" />
<Columns>
<dx:GridViewCommandColumn ShowDeleteButton="True" ShowEditButton="True" ShowInCustomizationForm="True"
ShowNewButtonInHeader="True" VisibleIndex="0">
</dx:GridViewCommandColumn>
<dx:GridViewDataTextColumn FieldName="UniqueID" ReadOnly="True" ShowInCustomizationForm="True"
Visible="False" VisibleIndex="1">
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="ResourceID" ShowInCustomizationForm="True" Visible="False"
VisibleIndex="2" ReadOnly="True">
<EditFormSettings Visible="False" />
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="ResourceName" ShowInCustomizationForm="True" VisibleIndex="3">
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="Color" ShowInCustomizationForm="True" Visible="False" VisibleIndex="4">
<EditFormSettings Visible="False" />
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="CustomField1" ShowInCustomizationForm="True" Visible="False" VisibleIndex="5">
<EditFormSettings Visible="False" />
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="category_ClientID" ShowInCustomizationForm="True"
VisibleIndex="6" Visible="False">
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="IsAvailable" PropertiesTextEdit-NullDisplayText="true"
ShowInCustomizationForm="True" VisibleIndex="7">
**<EditItemTemplate>
<dx:ASPxCheckBox ID="chkIsAvailableEdit" runat="server" Checked="true" Style="margin-left: 18px"
CheckState="Checked" Cursor="pointer" EnableDefaultAppearance="False"
EnableTheming="False">
<CheckedImage Height="26px" Url="~/images/switchon.png" Width="70px">
</CheckedImage>
<UncheckedImage Height="26px" Url="~/images/switchoff.png" Width="70px">
</UncheckedImage>
<GrayedImage Url="~/images/switchoff.png">
</GrayedImage>
</dx:ASPxCheckBox>
</EditItemTemplate>**
</dx:GridViewDataTextColumn>
</Columns>
</dx:ASPxGridView>
<asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:NCompassWebsiteConnectionString %>"
DeleteCommand="DELETE FROM [SchResources] WHERE [UniqueID] = #UniqueID"
InsertCommand="INSERT INTO [SchResources] ([ResourceID], [ResourceName], [Color], [CustomField1], [category_ClientID],
[IsAvailable]) VALUES (#ResourceID, #ResourceName, #Color, #CustomField1, #category_ClientID, #IsAvailable)"
SelectCommand="SELECT * FROM [SchResources] WHERE ([category_ClientID] = #category_ClientID)"
UpdateCommand="UPDATE [SchResources] SET [ResourceID] = #ResourceID, [ResourceName] = #ResourceName, [Color] = #Color,
[CustomField1] = #CustomField1, [category_ClientID] = #category_ClientID, [IsAvailable] = #IsAvailable WHERE [UniqueID] = #UniqueID">
<DeleteParameters>
<asp:Parameter Name="UniqueID" Type="Int32" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="ResourceID" Type="Int32" />
<asp:Parameter Name="ResourceName" Type="String" />
<asp:Parameter Name="Color" Type="Int32" />
<asp:Parameter Name="CustomField1" Type="String" />
<asp:SessionParameter Name="category_ClientID" SessionField="ClientID" Type="String" />
<asp:Parameter Name="IsAvailable" Type="String" />
</InsertParameters>
<SelectParameters>
<asp:SessionParameter Name="category_ClientID" SessionField="ClientID" Type="String" />
<%--<asp:Parameter DefaultValue="62" Name="category_ClientID" Type="String" />--%>
</SelectParameters>
<UpdateParameters>
<asp:Parameter Name="ResourceID" Type="Int32" />
<asp:Parameter Name="ResourceName" Type="String" />
<asp:Parameter Name="Color" Type="Int32" />
<asp:Parameter Name="CustomField1" Type="String" />
<asp:SessionParameter Name="category_ClientID" SessionField="ClientID" Type="String" />
<asp:Parameter Name="IsAvailable" Type="String" />
<asp:Parameter Name="UniqueID" Type="Int32" />
</UpdateParameters>
</asp:SqlDataSource>
Simply use the built-in GridViewDataCheckColumn (specially intended for displaying/editing boolean values) instead of the GridViewDataTextColumn (the default) one:
<%--
<dx:GridViewDataTextColumn FieldName="IsAvailable">
</dx:GridViewDataTextColumn
--%>
<dx:GridViewDataCheckColumn FieldName="IsAvailable">
</dx:GridViewDataCheckColumn
Check this demo.
Or, use the standard two-way binding expression (the Bind method) to bind ASPxCheckBox with the necessary row's FieldName:
<dx:GridViewDataTextColumn FieldName="IsAvailable">
<EditItemTemplate>
<dx:ASPxCheckBox ID="chkIsAvailableEdit" ... Value='<%#Bind("IsAvailable")'>
</dx:ASPxCheckBox>
</EditItemTemplate>
</dx:GridViewDataTextColumn>
Check this demo.
Related
<asp:GridView ID="dgvCustomers" runat="server" AutoGenerateColumns="False" HorizontalAlign="Center" DataKeyNames="ID" DataSourceID="dsCustomerTickets" BackColor="White" BorderColor="#DEDFDE" BorderStyle="None" BorderWidth="1px" CellPadding="4" ForeColor="Black" GridLines="Vertical" OnRowUpdated="dgvCustomers_RowUpdated">
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:CommandField EditImageUrl="~/svg/edit.png" UpdateImageUrl="~/svg/save.png" CancelImageUrl="~/svg/cancel.png" ButtonType="Image" ShowEditButton="True" />
<asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" ReadOnly="True" SortExpression="ID" />
<asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" />
<asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" />
<asp:BoundField DataField="System" HeaderText="System" SortExpression="System" />
<asp:BoundField DataField="LoggedDate" HeaderText="LoggedDate" SortExpression="LoggedDate" />
<asp:BoundField DataField="ClosedDate" HeaderText="ClosedDate" SortExpression="ClosedDate" />
<asp:BoundField DataField="Resolution" HeaderText="Resolution" SortExpression="Resolution" />
<%--<asp:BoundField DataField="HistoryID" HeaderText="HistoryID" SortExpression="HistoryID" />--%>
<%--<asp:BoundField DataField="Priority" HeaderText="Priority" SortExpression="Priority" />--%>
<asp:BoundField DataField="LoggedBy" HeaderText="LoggedBy" SortExpression="LoggedBy" />
<asp:TemplateField HeaderText="State" SortExpression="State2">
<EditItemTemplate>
<asp:DropDownList ID="ddlstate" runat="server" DataSourceID="SqlDataSource2" DataTextField="State" DataValueField="ID" SelectedValue='<%# Bind("State") %>' AppendDataBoundItems="true">
<asp:ListItem Text="Select a State" Value="" />
</asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("State2") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Priority" SortExpression="State3">
<EditItemTemplate>
<asp:DropDownList ID="ddlpriority" runat="server" DataSourceID="SqlDataSource3" DataTextField="Priority" DataValueField="ID" SelectedValue='<%# Bind("Priority") %>' AppendDataBoundItems="true">
<asp:ListItem Text="Select Priority" Value="" />
</asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("State3") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="#CCCC99" />
<HeaderStyle BackColor="#6B696B" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#F7F7DE" ForeColor="Black" HorizontalAlign="Right" />
<RowStyle BackColor="#F7F7DE" />
<SelectedRowStyle BackColor="#0099ff" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#FBFBF2" />
<SortedAscendingHeaderStyle BackColor="#848384" />
<SortedDescendingCellStyle BackColor="#EAEAD3" />
<SortedDescendingHeaderStyle BackColor="#575357" />
</asp:GridView>
<asp:SqlDataSource ID="dsCustomerTickets" runat="server" ConnectionString="<%$ ConnectionStrings:TicketsSupportConnectionString %>" DeleteCommand="DELETE FROM [Tickets] WHERE [ID] = #ID" InsertCommand="INSERT INTO [Tickets] ([Title], [Description], [System], [LoggedDate], [ClosedDate], [Resolution], [Priority], [HistoryID], [LoggedBy], [State]) VALUES (#Title, #Description, #System, #LoggedDate, #ClosedDate, #Resolution, #Priority, #HistoryID, #LoggedBy, #State)" SelectCommand="SELECT T.ID, T.Title, T.Description, T.System, T.Attachments, T.LoggedDate, T.ClosedDate, T.Resolution, T.Priority, T.LoggedBy, S.State AS State2, p.Priority AS State3 FROM Tickets AS T INNER JOIN State AS S ON T.State = S.ID INNER JOIN Priority AS p ON T.Priority = p.ID WHERE (T.LoggedBy = #LoggedBy)" UpdateCommand="UPDATE Tickets SET Description = #Description, System = #System, ClosedDate = #ClosedDate, Resolution = #Resolution, Priority = #Priority, HistoryID = #HistoryID, State = #State WHERE (ID = #ID)">
<DeleteParameters>
<asp:Parameter Name="ID" Type="Int32" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="Title" Type="String" />
<asp:Parameter Name="Description" Type="String" />
<asp:Parameter Name="System" Type="String" />
<asp:Parameter Name="LoggedDate" Type="DateTime" />
<asp:Parameter Name="ClosedDate" Type="DateTime" />
<asp:Parameter Name="Resolution" Type="String" />
<asp:Parameter Name="Priority" Type="Int32" />
<asp:Parameter Name="HistoryID" Type="Int32" />
<asp:Parameter Name="LoggedBy" Type="String" />
<asp:Parameter Name="State" Type="Int32" />
</InsertParameters>
<SelectParameters>
<asp:QueryStringParameter Name="LoggedBy" QueryStringField="u" />
</SelectParameters>
<UpdateParameters>
<asp:Parameter Name="Description" Type="String" />
<asp:Parameter Name="System" Type="String" />
<asp:Parameter Name="ClosedDate" Type="DateTime" />
<asp:Parameter Name="Resolution" Type="String" />
<asp:Parameter Name="Priority" Type="Int32" />
<asp:Parameter Name="HistoryID" Type="Int32" />
<asp:Parameter Name="State" Type="Int32" />
<asp:Parameter Name="ID" Type="Int32" />
</UpdateParameters>
</asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:TicketsSupportConnectionString %>" SelectCommand="SELECT [ID],[State] FROM [dbo].[State]"></asp:SqlDataSource>
With the above code I get the error constantly.
In SQL if I run the SqlDataSource2 query I get results (ID and State).
I tried Changing my queries and editing my dragged SqlDataSource2 in the query builder.
As soon as I click on the commandfield "EditImageUrl" I get the above error.
Maybe I am looking at my code to long to notice any issues.
I have googled it with no luck looking at stuff like:
I have looked at Here
And the same here, I have bind instead of Eval in the dropdown list.
I also tried changing my sqldatasource to:
Select * from State
Select ID, State from State
Select ID, State from dbo.State
Any help will be appreciated.
Edit and Update
In EditTemplate you fill in aspDropDown from SqlDataSource2 with correct DataTextField="State" DataValueField="ID". But SelectedValue belongs to <asp:SqlDataSource ID="dsCustomerTickets". So you need T.State in SelectCommand to make binding SelectedValue='<%# Bind("State") %>' correct. Also there is no need in Bind in ItemTemplate. Eval("State2") is enough.
And 1st SqlDataSource should be
<asp:SqlDataSource ID="dsCustomerTickets" runat="server"
ConnectionString="<%$ ConnectionStrings:TicketsSupportConnectionString %>"
DeleteCommand="DELETE FROM [Tickets] WHERE [ID] = #ID"
InsertCommand="INSERT INTO [Tickets] (/*removed for shortness*/ [State]) VALUES ( #State2)"
SelectCommand="SELECT /*your list*/ T.State, S.State AS State2, p.Priority AS State3 FROM Tickets AS T INNER JOIN State AS S ON T.State = S.ID INNER JOIN Priority AS p ON T.Priority = p.ID WHERE (T.LoggedBy = #LoggedBy)"
UpdateCommand="UPDATE Tickets SET /*removed for shortness*/ State = #State2 WHERE (ID = #ID)">
<DeleteParameters>
<asp:Parameter Name="ID" Type="Int32" />
</DeleteParameters>
<InsertParameters>
<%--your parameters removed for shortness--%>
<asp:Parameter Name="State" Type="Int32" />
</InsertParameters>
<SelectParameters>
<asp:QueryStringParameter Name="LoggedBy" QueryStringField="u" />
</SelectParameters>
<UpdateParameters>
<%--your parameters removed for shortness--%>
<asp:Parameter Name="State" Type="Int32" />
<asp:Parameter Name="ID" Type="Int32" />
</UpdateParameters>
</asp:SqlDataSource>
So I have a gridview that is bounded with a sql data source. After that I changed a edit template for one column and instead of textBox I used a dropdownlist. In that dropdownlist I entered two items and their values. Now when I update a gridview column where I installed dropdownlist doesn't update it old value to its new value but gets a NULL value.
This is my code:
<asp:GridView ID="gvNeobrađene" HorizontalAlign="Center" runat="server" AutoGenerateColumns="False" DataKeyNames="Id" DataSourceID="sdsNeobradene" CellPadding="4" ForeColor="#333333" GridLines="None" OnRowUpdating="gvNeobrađene_RowUpdating">
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:BoundField DataField="Id" HeaderText="Id" InsertVisible="False" ReadOnly="True" SortExpression="Id" />
<asp:BoundField DataField="Ime" HeaderText="Ime" SortExpression="Ime" />
<asp:BoundField DataField="Prezime" HeaderText="Prezime" SortExpression="Prezime" />
<asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" />
<asp:BoundField DataField="Telefon" HeaderText="Telefon" SortExpression="Telefon" />
<asp:BoundField DataField="Napomena" HeaderText="Napomena" SortExpression="Napomena" />
<asp:BoundField DataField="SeminarID" HeaderText="SeminarID" SortExpression="SeminarID" />
<asp:BoundField DataField="TerminID" HeaderText="TerminID" SortExpression="TerminID" />
<asp:CheckBoxField DataField="PotvrdaP" HeaderText="PotvrdaP" SortExpression="PotvrdaP" ReadOnly="false"/>
<asp:TemplateField HeaderText="v" SortExpression="StatusP">
<EditItemTemplate>
<asp:DropDownList ID="ddlStatus" runat="server">
<asp:ListItem Value="Prihvaćena">Prihvaćena</asp:ListItem>
<asp:ListItem Value="Odbijena">Odbijena</asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("StatusP") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:CommandField ButtonType="Button" CancelText="Odustani" DeleteText="Izbriši" EditText="Uredi" InsertText="Ubaci" NewText="Novo" SelectText="Odaberi" ShowEditButton="True" ShowHeader="True" UpdateText="Spremi" ShowDeleteButton="True" />
</Columns>
<EditRowStyle BackColor="#2461BF" />
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#EFF3FB" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#F5F7FB" />
<SortedAscendingHeaderStyle BackColor="#6D95E1" />
<SortedDescendingCellStyle BackColor="#E9EBEF" />
<SortedDescendingHeaderStyle BackColor="#4870BE" />
</asp:GridView>
<asp:SqlDataSource ID="sdsNeobradene" runat="server" ConflictDetection="CompareAllValues" ConnectionString="<%$ ConnectionStrings:SeminarBazaConnectionString %>"
DeleteCommand="DELETE FROM [Predbiljezba] WHERE [Id] = #original_Id AND [Ime] = #original_Ime AND [Prezime] = #original_Prezime AND [Email] = #original_Email AND [Telefon] = #original_Telefon AND (([Napomena] = #original_Napomena) OR ([Napomena] IS NULL AND #original_Napomena IS NULL)) AND [SeminarID] = #original_SeminarID AND [TerminID] = #original_TerminID AND [PotvrdaP] = #original_PotvrdaP AND (([StatusP] = #original_StatusP) OR ([StatusP] IS NULL AND #original_StatusP IS NULL))" InsertCommand="INSERT INTO [Predbiljezba] ([Ime], [Prezime], [Email], [Telefon], [Napomena], [SeminarID], [TerminID], [PotvrdaP], [StatusP]) VALUES (#Ime, #Prezime, #Email, #Telefon, #Napomena, #SeminarID, #TerminID, #PotvrdaP, #StatusP)" OldValuesParameterFormatString="original_{0}"
SelectCommand="SELECT * FROM [Predbiljezba] WHERE ([PotvrdaP] = #PotvrdaP)"
UpdateCommand="UPDATE [Predbiljezba] SET [Ime] = #Ime, [Prezime] = #Prezime, [Email] = #Email, [Telefon] = #Telefon, [Napomena] = #Napomena, [SeminarID] = #SeminarID, [TerminID] = #TerminID, [PotvrdaP] = #PotvrdaP, [StatusP] = #StatusP WHERE [Id] = #original_Id">
<DeleteParameters>
<asp:Parameter Name="original_Id" Type="Int32" />
<asp:Parameter Name="original_Ime" Type="String" />
<asp:Parameter Name="original_Prezime" Type="String" />
<asp:Parameter Name="original_Email" Type="String" />
<asp:Parameter Name="original_Telefon" Type="String" />
<asp:Parameter Name="original_Napomena" Type="String" />
<asp:Parameter Name="original_SeminarID" Type="Int32" />
<asp:Parameter Name="original_TerminID" Type="Int32" />
<asp:Parameter Name="original_PotvrdaP" Type="Boolean" />
<asp:Parameter Name="original_StatusP" Type="String" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="Ime" Type="String" />
<asp:Parameter Name="Prezime" Type="String" />
<asp:Parameter Name="Email" Type="String" />
<asp:Parameter Name="Telefon" Type="String" />
<asp:Parameter Name="Napomena" Type="String" />
<asp:Parameter Name="SeminarID" Type="Int32" />
<asp:Parameter Name="TerminID" Type="Int32" />
<asp:Parameter Name="PotvrdaP" Type="Boolean" />
<asp:Parameter Name="StatusP" Type="String" />
</InsertParameters>
<SelectParameters>
<asp:Parameter DefaultValue="False" Name="PotvrdaP" Type="Boolean" />
</SelectParameters>
<UpdateParameters>
<asp:Parameter Name="Ime" Type="String" />
<asp:Parameter Name="Prezime" Type="String" />
<asp:Parameter Name="Email" Type="String" />
<asp:Parameter Name="Telefon" Type="String" />
<asp:Parameter Name="Napomena" Type="String" />
<asp:Parameter Name="SeminarID" Type="Int32" />
<asp:Parameter Name="TerminID" Type="Int32" />
<asp:Parameter Name="PotvrdaP" Type="Boolean" />
<asp:Parameter Name="StatusP" Type="String" />
<asp:Parameter Name="original_Id" Type="Int32" />
<asp:Parameter Name="original_Ime" Type="String" />
<asp:Parameter Name="original_Prezime" Type="String" />
<asp:Parameter Name="original_Email" Type="String" />
<asp:Parameter Name="original_Telefon" Type="String" />
<asp:Parameter Name="original_Napomena" Type="String" />
<asp:Parameter Name="original_SeminarID" Type="Int32" />
<asp:Parameter Name="original_TerminID" Type="Int32" />
<asp:Parameter Name="original_PotvrdaP" Type="Boolean" />
<asp:Parameter Name="original_StatusP" Type="String" />
</UpdateParameters>
</asp:SqlDataSource>
Is there any other stuff I need to change so this could work ?
You need to Bind your DropDownList to your database field
<asp:DropDownList ID="ddlStatus" runat="server"
SelectedValue='<%# Bind("StatusP") %>'>
<asp:ListItem Value="">None</asp:ListItem>
<asp:ListItem Value="Prihvaćena">Prihvaćena</asp:ListItem>
<asp:ListItem Value="Odbijena">Odbijena</asp:ListItem>
</asp:DropDownList>
The key part is
SelectedValue='<%# Bind("StatusP") %>'
This will cause the value you select to pass to your datasource.
I'm new to Asp.net and Telerik Control.
I'm using Radgrid to bind a View with schemabinding in SQL Server. And I want to use Telerik Radgrid AllowAutomaticInserts/updates/deletes functions. but there is no result return to database and no error occured. When should I use Insertcommand in code-behind? How to debug aspx file as following at runtime.
Thanks in advance.
Here is the code.
<asp:Panel ID="Project" runat="server" GroupingText="Project" CssClass="inlineBlock" Width="1600px" Font-Names="Microsoft YaHei UI"
BackColor ="#99ff99" BorderStyle="Double">
<asp:Label Text="CompanyName" runat="server" Font-Size="Small"></asp:Label>
<telerik:RadDropDownList ID="RadDropDownListCompany" runat="server" Skin="Windows7" Font-Size="Small" AutoPostBack="true" OnSelectedIndexChanged="RadDropDownListCompany_SelectedIndexChanged"
></telerik:RadDropDownList>
<asp:Label Text="Projectname" runat="server" Font-Size="Small"></asp:Label>
<telerik:RadDropDownList ID="RadDropDownListProject" runat="server" Skin="Windows7" Font-Size="Small" ></telerik:RadDropDownList>
<telerik:RadButton ID="btnQuery" runat="server" Text="Confirm" Skin="Windows7" Font-Size="Small" OnClick="btnQuery_Click" ></telerik:RadButton>
</asp:Panel>
<asp:Panel ID="PanelOp" runat="server" Visible="false" >
<asp:Label Text="LandBlock" runat="server" Font-Size="Medium" Font-Names="Microsoft YaHei UI"></asp:Label>
<telerik:RadDropDownList ID="RadDropDownListLandBlock" runat="server" Skin="Windows7" Font-Size="Small" Font-Names="Microsoft YaHei UI"></telerik:RadDropDownList>
<telerik:RadButton ID="radbtnLandBlockQuery" runat="server" Text="Confirm" Skin="Windows7" Font-Size="Small" OnClick="radbtnLandBlockQuery_Click" ></telerik:RadButton>
<telerik:RadGrid ID="RadGridLandBlockVoucher" runat="server" Skin="Windows7" Font-Size="Small" Font-Names="Microsoft YaHei UI" Culture="zh-CN"
Height="600px" Width="1600px" GroupPanelPosition="Top" ShowFooter ="True" EnableViewState="true" AutoGenerateEditColumn="true" AutoGenerateDeleteColumn="true"
AllowAutomaticInserts="true" AllowAutomaticUpdates="true" AllowAutomaticDeletes="true" OnNeedDataSource="RadGridLandBlockVoucher_NeedDataSource" >
<ClientSettings>
<Scrolling AllowScroll="True" UseStaticHeaders="True" />
</ClientSettings>
<MasterTableView AutoGenerateColumns="False" DataKeyNames="PK_Landdetail" CommandItemDisplay="Top"
CommandItemSettings-AddNewRecordText="Add" >
<Columns>
<telerik:GridBoundColumn DataField="PK_Landdetail" DataType="System.Guid" FilterControlAltText="Filter PK_Landdetail column" HeaderText="PK_Landdetail" ReadOnly="True" SortExpression="PK_Landdetail" UniqueName="PK_Landdetail" Visible="false" >
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="PK_location" DataType="System.Int32" FilterControlAltText="Filter PK_location column" HeaderText="PK_location" SortExpression="PK_location" UniqueName="PK_location" Visible="false" ReadOnly="true" >
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="ProjectName" FilterControlAltText="Filter ProjectName column" HeaderText="ProjectName" SortExpression="ProjectName" UniqueName="ProjectName" ReadOnly="true" >
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="PK_land" DataType="System.Guid" FilterControlAltText="Filter PK_land column" HeaderText="PK_land" SortExpression="PK_land" UniqueName="PK_land" Visible="false" ReadOnly="true" >
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="LandBlockNumber" FilterControlAltText="Filter LandBlockNumber column" HeaderText="LandBlockNumber" SortExpression="LandBlockNumber" UniqueName="LandBlockNumber" ReadOnly="true" >
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="PK_ccode" DataType="System.Int32" FilterControlAltText="Filter PK_ccode column" HeaderText="PK_ccode" SortExpression="PK_ccode" UniqueName="PK_ccode" Visible="false" ReadOnly="true" >
</telerik:GridBoundColumn>
<telerik:GridTemplateColumn FilterControlAltText="Filter ccodenamefull column" HeaderText="科目" SortExpression="ccodenamefull" UniqueName="ccodenamefull">
<ItemTemplate>
<%# Eval("ccodenamefull") %>
</ItemTemplate>
<EditItemTemplate>
<telerik:RadDropDownList runat="server" ID="RadDropDownListCcode" DataSourceID="SqlDataSourceccode" DataValueField="PK_ccode" DataTextField="ccodenamefull" SelectedValue='<%# Eval ("ccodenamefull") %>' Width="200px" ></telerik:RadDropDownList>
</EditItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridBoundColumn DataField="PayableAmount" DataType="System.Decimal" FilterControlAltText="Filter PayableAmount column" HeaderText="PayableAmount" SortExpression="PayableAmount" UniqueName="PayableAmount">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="ActualAmount" DataType="System.Decimal" FilterControlAltText="Filter ActualAmount column" HeaderText="ActualAmount" SortExpression="ActualAmount" UniqueName="ActualAmount">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="ContractNo" FilterControlAltText="Filter ContractNo column" HeaderText="ContractNo" SortExpression="ContractNo" UniqueName="ContractNo">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="ContractName" FilterControlAltText="Filter ContractName column" HeaderText="ContractName" SortExpression="ContractName" UniqueName="ContractName">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="LandTransferArea" DataType="System.Decimal" FilterControlAltText="Filter LandTransferArea column" HeaderText="LandTransferArea" SortExpression="LandTransferArea" UniqueName="LandTransferArea">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="LandLisenceArea" DataType="System.Decimal" FilterControlAltText="Filter LandLisenceArea column" HeaderText="LandLisenceArea" SortExpression="LandLisenceArea" UniqueName="LandLisenceArea">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="LisenceNo" FilterControlAltText="Filter LisenceNo column" HeaderText="LisenceNo" SortExpression="LisenceNo" UniqueName="LisenceNo">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="InvoiceAmount" DataType="System.Decimal" FilterControlAltText="Filter InvoiceAmount column" HeaderText="InvoiceAmount" SortExpression="InvoiceAmount" UniqueName="InvoiceAmount">
</telerik:GridBoundColumn>
<telerik:GridTemplateColumn DataField="LisenceStartDate" DataType="System.DateTime" FilterControlAltText="Filter LisenceStartDate column" HeaderText="证照起始日" SortExpression="LisenceStartDate" UniqueName="LisenceStartDate">
<ItemTemplate>
<%# Eval("LisenceStartDate") %>
</ItemTemplate>
<EditItemTemplate>
<telerik:RadDatePicker ID="RadDatePickerLisenceStartDate" runat="server" DbSelectedDate= '<%# Bind("LisenceStartDate") %>' MinDate="1900-1-1" ></telerik:RadDatePicker>
</EditItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridBoundColumn DataField="LisenceEndDate" DataType="System.DateTime" FilterControlAltText="Filter LisenceEndDate column" HeaderText="LisenceEndDate" SortExpression="LisenceEndDate" UniqueName="LisenceEndDate">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Note" FilterControlAltText="Filter Note column" HeaderText="Note" SortExpression="Note" UniqueName="Note">
</telerik:GridBoundColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
<asp:SqlDataSource ID="SqlDataSourceLandblockCostView" runat="server" ConnectionString="<%$ ConnectionStrings:myAsystemstring %>"
SelectCommand="SELECT * FROM [LD_LandblockCostView] WHERE [PK_location] = #PK_location AND [PK_land] = #PK_land"
DeleteCommand="delete * from [LD_LandblockCostView] WHERE PK_Landdetail=#PK_Landdetail"
InsertCommand ="INSERT INTO [LD_LandblockCostView] ([PK_location], [PK_land], [PK_ccode], [PayableAmount], [ActualAmount], [ContractNo], [ContractName], [LandTransferArea], [LandLisenceArea], [LisenceNo], [invoiceAmount], [Note], [LisenceStartDate], [LisenceEndDate])
VALUES (#PK_location,#PK_land, #PK_ccode,#PayableAmount, #ActualAmount, #ContractNo,#ContractName,#LandTransferArea,#LandLisenceArea,#LisenceNo,#invoiceAmount,#Note,#LisenceStartDate,#LisenceEndDate)"
UpdateCommand="UPDATE [LD_LandblockCostView] SET [PK_ccode] = #PK_ccode, [PayableAmount] = #PayableAmount, [ActualAmount]=#ActualAmount,[ContractNo]=#ContractNo,[ContractName]=#ContractName,[LandTransferArea]=#LandTransferArea,[LandLisenceArea]=#LandLisenceArea,[LisenceNo]=#LisenceNo,[invoiceAmount]=#invoiceAmount,[Note]=#Note,[LisenceStartDate]=#LisenceStartDate,[LisenceEndDate]=#LisenceEndDate
WHERE [PK_Landdetail] = #PK_Landdetail" >
<SelectParameters>
<asp:ControlParameter ControlID="RadDropDownListProject" Name="PK_location" PropertyName="SelectedValue" Type="Int32" />
<asp:ControlParameter ControlID="RadDropDownListLandBlock" Name="PK_land" PropertyName="SelectedValue" Type="String" />
</SelectParameters>
<DeleteParameters>
<asp:Parameter Name ="PK_Landdetail" Type="String" />
</DeleteParameters>
<InsertParameters>
<asp:ControlParameter Name="PK_location" Type="Int32" ControlID="RadDropDownListCompany" PropertyName="SelectedValue" />
<asp:ControlParameter Name="PK_land" Type="String" ControlID="RadDropDownListLandBlock" PropertyName="SelectedValue" />
<asp:ControlParameter Name="PK_ccode" Type="Int32" ControlID="RadDropDownListCcode" PropertyName ="SelectedValue" />
<asp:Parameter Name="PayableAmount" Type="Decimal" />
<asp:Parameter Name="ActualAmount" Type="Decimal" />
<asp:Parameter Name="ContractNo" Type="String" />
<asp:Parameter Name="ContractName" Type="String" />
<asp:Parameter Name="LandTransferArea" Type="Decimal" />
<asp:Parameter Name="LandLisenceArea" Type="Decimal" />
<asp:Parameter Name="LisenceNo" Type="String" />
<asp:Parameter Name="invoiceAmount" Type="Decimal" />
<asp:Parameter Name="Note" Type="String" />
<asp:Parameter Name="LisenceStartDate" Type ="DateTime" />
<asp:Parameter Name="LisenceEndDate" Type="DateTime" />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name ="PK_ccode" Type="Int32" />
<asp:Parameter Name="PayableAmount" Type="Decimal" />
<asp:Parameter Name="ActualAmount" Type="Decimal" />
<asp:Parameter Name="ContractNo" Type="String" />
<asp:Parameter Name="ContractName" Type="String" />
<asp:Parameter Name="LandTransferArea" Type="Decimal" />
<asp:Parameter Name="LandLisenceArea" Type="Decimal" />
<asp:Parameter Name="LisenceNo" Type="String" />
<asp:Parameter Name="invoiceAmount" Type="Decimal" />
<asp:Parameter Name="Note" Type="String" />
<asp:Parameter Name="LisenceStartDate" Type ="DateTime" />
<asp:Parameter Name="LisenceEndDate" Type="DateTime" />
</UpdateParameters>
</asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSourceccode" runat="server" ConnectionString="<%$ ConnectionStrings:myAsystemstring %>" SelectCommand="SELECT [PK_ccode], [ccodenamefull] FROM [Ref_ccodenameLandBlockCost]" ></asp:SqlDataSource>
</asp:Panel>
Code-behind
protected void RadGridLandBlockVoucher_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
RadGridLandBlockVoucher.DataSource = SqlDataSourceLandblockCostView;
}
You have the SQL queries defined in a declarative data source. Use that for the DataSourceID of the grid and remove the NeedDataSource handler. The SELECT query will handler your data retrieval.
If you want to use the NeedDataSource event to use some custom data access layer/logic, you should then disable the automatic operations and use the events to write your own code according to your logic/DAL.
I am fairly new at ASP.NET c#. I would like to edit a detailsview with a dropdown list. I have followed the instructions on this link -- This link-- and it was exactly what I orrigionally thought of. This is flawed however, because although I can see the items on my dropdown list, it does not actually update the database. I am at a loss. I have been trying to find an answer for a couple of days now and am unsure of what I need to do. Is there something I need to do in the backend? I will attach my code at the end as well. Currently I have nothing going on in the backend.
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:it_supportConnectionString %>" DeleteCommand="DELETE FROM [issues] WHERE [issue_id] = #issue_id" InsertCommand="INSERT INTO [issues] ([requestor], [email], [urgency], [issue_type], [details], [priority], [issue_manager], [status], [date_reported]) VALUES (#requestor, #email, #urgency, #issue_type, #details, #priority, #issue_manager, #status, #date_reported)" SelectCommand="SELECT issues.issue_id, issues.requestor, issues.email, issues.phone, issues.urgency, issues.issue_type_id,Issue_Type.[Issue_Type_ID], Issue_Type.[Issue_Type], issues.details, issues.priority, issues.issue_manager, issues.status, issues.date_reported, issues.notes FROM issues LEFT OUTER JOIN Issue_Type ON Issue_Type.Issue_Type_Id = issues.issue_type_id WHERE (issues.issue_id = #issue_id)" UpdateCommand="UPDATE issues SET requestor = #requestor, email = #email, urgency = #urgency, details = #details, priority = #priority, issue_manager = #issue_manager, status = #status, date_reported = #date_reported WHERE (issue_id = #issue_id)">
<DeleteParameters>
<asp:Parameter Name="issue_id" Type="Int32" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="requestor" Type="String" />
<asp:Parameter Name="email" Type="String" />
<asp:Parameter Name="urgency" Type="String" />
<asp:Parameter Name="issue_type" Type="String" />
<asp:Parameter Name="details" Type="String" />
<asp:Parameter Name="priority" Type="Int32" />
<asp:Parameter Name="issue_manager" Type="String" />
<asp:Parameter Name="status" Type="String" />
<asp:Parameter Name="date_reported" Type="DateTime" />
</InsertParameters>
<SelectParameters>
<asp:QueryStringParameter Name="issue_id" QueryStringField="id" Type="Int32" />
</SelectParameters>
<UpdateParameters>
<asp:Parameter Name="requestor" Type="String" />
<asp:Parameter Name="email" Type="String" />
<asp:Parameter Name="urgency" Type="String" />
<asp:Parameter Name="details" Type="String" />
<asp:Parameter Name="priority" Type="Int32" />
<asp:Parameter Name="issue_manager" Type="String" />
<asp:Parameter Name="status" Type="String" />
<asp:Parameter Name="date_reported" Type="DateTime" />
<asp:Parameter Name="issue_id" Type="Int32" />
</UpdateParameters>
</asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:it_supportConnectionString %>" SelectCommand="SELECT Issue_Type.Issue_Type_Id, Issue_Type.Issue_Type, issues.issue_type_id AS Expr1 FROM Issue_Type LEFT OUTER JOIN issues ON Issue_Type.Issue_Type_Id = issues.issue_type_id"></asp:SqlDataSource>
<asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" BackColor="#DEBA84" BorderColor="#DEBA84" BorderStyle="None" BorderWidth="1px" CellPadding="3" CellSpacing="2" DataSourceID="SqlDataSource1" Height="50px" Width="125px">
<EditRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="White" />
<Fields>
<asp:BoundField DataField="issue_id" HeaderText="issue_id" InsertVisible="False" ReadOnly="True" SortExpression="issue_id" />
<asp:BoundField DataField="requestor" HeaderText="requestor" SortExpression="requestor" />
<asp:BoundField DataField="email" HeaderText="email" SortExpression="email" />
<asp:BoundField DataField="phone" HeaderText="phone" SortExpression="phone" />
<asp:BoundField DataField="urgency" HeaderText="urgency" SortExpression="urgency" />
<asp:TemplateField HeaderText="issue_type_id" SortExpression="issue_type_id">
<EditItemTemplate>
<asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="SqlDataSource2" DataTextField="Issue_Type_Id" DataValueField="Expr1" SelectedValue='<%# Bind("issue_type_id") %>'>
</asp:DropDownList>
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("issue_type_id") %>'></asp:TextBox>
</InsertItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("issue_type_id") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Issue_Type" HeaderText="Issue_Type" SortExpression="Issue_Type" />
<asp:BoundField DataField="details" HeaderText="details" SortExpression="details" />
<asp:BoundField DataField="priority" HeaderText="priority" SortExpression="priority" />
<asp:BoundField DataField="issue_manager" HeaderText="issue_manager" SortExpression="issue_manager" />
<asp:BoundField DataField="status" HeaderText="status" SortExpression="status" />
<asp:BoundField DataField="date_reported" HeaderText="date_reported" SortExpression="date_reported" />
<asp:BoundField DataField="notes" HeaderText="notes" SortExpression="notes" />
<asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
</Fields>
<FooterStyle BackColor="#F7DFB5" ForeColor="#8C4510" />
<HeaderStyle BackColor="#A55129" Font-Bold="True" ForeColor="White" />
<PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" />
<RowStyle BackColor="#FFF7E7" ForeColor="#8C4510" />
</asp:DetailsView>
I have the following problem: I have 2 tables:
1) table1: STRANKA (ID_STRANKE(primary key), IME, PRIIMEK, TELEFON, NASLOV, POSTA)
2) table2: VOZILO (REG_STEVILKA(primary key), ID_STRANKE, ZNAMKA, MODEL, LETO_IZDELAVE, PROSTORNINA_MOTORJA, MOC_MOTORJA, TIP_MOTORJA, VIN_STEVILKA)
Each member of "STRANKA" can have 0:n members of "VOZILO", while each member of "VOZILO" has exactly 1 member from "STRANKA".
Now, I have DetailsView (DetailsView2 is actual name in code) which displays all columns from a certain member of "VOZILO". Now - what I want to do is to replace the column "ID_STRANKE" with "IME + PRIIMEK". To do this I must somehow connect these two tables or something ... I really don't know how to do it. Can somebody help? Thanks!
<%# 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>
<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>
You need to join your 2 data tables. I've combined the two columns from STRANKE as one column and added STRANKE_ID as a data key, you could return them separately and use a template field :
<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>
On a side note, next time just supply the needed information. It was quite hard to find the relevant details view and SQLDataSource in all that code