My database is oracle. and i use sqldatasource to access database. My RadGrid's datasource is the sqldatatabase. the oracle database have no bool datatype. So some fields i used the number 0 and 1 instead. the 1 is true and the 0 is false. in the radgrid. I show the field by checkbox. the code like this:
<asp:CheckBox id="chkBool" checked='<%# DataBinder(Container,"DataItem.SomeField").ToString()=="1"?true:false %>' />
so how can it automatic update or insert the data to oracle?
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="DataEditor.aspx.cs" Inherits="Default2" %>
<%@ Register TagPrefix="sds" Namespace="Telerik.Web.SessionDS" %>
<asp:Content ID="Content1" ContentPlaceHolderID="GlobeContentPH" Runat="Server">
<link href="styles/style/css/main.css" rel="stylesheet" type="text/css" />
<style type="text/css">
.MyImageButton
{
cursor: hand;
}
.EditFormHeader td
{
font-size: 14px;
padding: 4px !important;
color: #0066cc;
}
</style>
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="RadGrid1">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="RadGrid1" />
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
</telerik:RadAjaxManager>
<table style=" width:100%; border:0px">
<tr style=" width:100%">
<td style=" width:100%">
<div id="RadGrid" style="width:100%">
<telerik:RadGrid ID="RadGrid1" AllowAutomaticUpdates="True" Width="100%" AllowAutomaticDeletes="True"
DataSourceID="SqlDataSource1" AllowSorting="True"
AllowPaging="True" runat="server" ShowFooter="True" AllowMultiRowSelection="True"
PageSize="20" AllowMultiRowEdit="True" AllowAutomaticInserts="True" OnItemUpdated="RadGrid1_ItemUpdated"
Skin="Vista" GridLines="None">
<PagerStyle Mode="NextPrevAndNumeric" />
<MasterTableView Width="100%" CommandItemDisplay="Top"
DataSourceID="SqlDataSource1" AutoGenerateColumns="False">
<Columns>
<telerik:GridBoundColumn DataField="序号" DataType="System.Decimal"
HeaderText="序号" SortExpression="序号" UniqueName="序号">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="作业区" HeaderText="作业区" SortExpression="作业区"
UniqueName="作业区">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="监测点代号" DataType="System.Decimal"
HeaderText="监测点代号" SortExpression="监测点代号" UniqueName="监测点代号">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="监测点名称" HeaderText="监测点名称"
SortExpression="监测点名称" UniqueName="监测点名称">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="监测点部位" HeaderText="监测点部位"
SortExpression="监测点部位" UniqueName="监测点部位">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="建点日期" DataType="System.DateTime"
HeaderText="建点日期" SortExpression="建点日期" UniqueName="建点日期">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="氢探针" HeaderText="氢探针" SortExpression="氢探针"
UniqueName="氢探针" DataType="System.Decimal">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="电阻探针" HeaderText="电阻探针"
SortExpression="电阻探针" UniqueName="电阻探针" DataType="System.Decimal">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="试片失重法" HeaderText="试片失重法"
SortExpression="试片失重法" UniqueName="试片失重法" DataType="System.Decimal">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="介质"
HeaderText="介质" SortExpression="介质" UniqueName="介质">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="管线材质" HeaderText="管线材质" SortExpression="管线材质"
UniqueName="管线材质">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="管线规格" HeaderText="管线规格"
SortExpression="管线规格" UniqueName="管线规格">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="报废日期" HeaderText="报废日期"
SortExpression="报废日期" UniqueName="报废日期" DataType="System.DateTime">
</telerik:GridBoundColumn>
<%-- <telerik:GridBoundColumn DataField="是否现用" HeaderText="是否现用"
SortExpression="是否现用" UniqueName="是否现用" DataType="System.Decimal">
</telerik:GridBoundColumn>--%>
<telerik:GridTemplateColumn DataField="是否现用" HeaderText="是否现用"
SortExpression="是否现用" UniqueName="是否现用">
<ItemTemplate>
<asp:CheckBox ID="CheckBox1" Checked='<%# (DataBinder.Eval( Container, "DataItem.是否现用")).ToString()=="1"?true:false %>' runat="server" />
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridBoundColumn DataField="备注" HeaderText="备注" SortExpression="备注"
UniqueName="备注">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="管道名称" HeaderText="管道名称"
SortExpression="管道名称" UniqueName="管道名称">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="场站名称" HeaderText="场站名称"
SortExpression="场站名称" UniqueName="场站名称">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="照片ID" HeaderText="照片ID"
SortExpression="照片ID" UniqueName="照片ID">
</telerik:GridBoundColumn>
</Columns>
<EditFormSettings EditFormType="Template">
<FormTemplate>
<div>
<div id="show_title"></div>
<div id="show_area"></div>
<div id="show_main_edit">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td class="show_main_td_first" >序 号:</td>
<td class="show_main_td_last">
<asp:TextBox Width="80%" ID="PipsegmentCode" Text='<%# DataBinder.Eval( Container, "DataItem.序号" ) %>' runat="server"></asp:TextBox>
</td>
<td class="show_main_td_last">作 业 区:</td>
<td class="show_main_td_last">
<asp:DropDownList ID="DropDownList1" Width="39%" runat="server">
</asp:DropDownList>
<asp:DropDownList ID="DropDownList2" Width="39%" runat="server">
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="show_main_td_first" >监测点代号:</td>
<td class="show_main_td_last">
<asp:TextBox Width="80%" ID="PipeSegmentLength" Text='<%# DataBinder.Eval( Container, "DataItem.监测点代号" ) %>' runat="server"></asp:TextBox>
</td>
<td class="show_main_td_last">监测点名称:</td>
<td class="show_main_td_last">
<asp:TextBox runat="server" Text='<%# DataBinder.Eval( Container, "DataItem.监测点名称" ) %>' Width="80%" ID="PipeDiameter"></asp:TextBox>
</td>
</tr>
<tr>
<td class="show_main_td_first">监测点部位:</td>
<td class="show_main_td_last">
<asp:TextBox ID="PipeThickness" Text='<%# DataBinder.Eval( Container, "DataItem.监测点部位" ) %>' Width="80%" runat="server"></asp:TextBox>
</td>
<td class="show_main_td_last">管线规格:</td>
<td class="show_main_td_last">
<asp:TextBox ID="SteelClass" Text='<%# DataBinder.Eval( Container, "DataItem.管线规格" ) %>' Width="80%" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td class="show_main_td_first" >管线材质:</td>
<td class="show_main_td_last">
<asp:TextBox ID="MadeStyle" Text='<%# DataBinder.Eval( Container, "DataItem.管线材质" ) %>' Width="80%" runat="server"></asp:TextBox>
</td>
<td class="show_main_td_last">介 质:</td>
<td class="show_main_td_last">
<asp:TextBox ID="JointMethod" Text='<%# DataBinder.Eval( Container, "DataItem.介质" ) %>' Width="80%" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td class="show_main_td_first">试片失重法:</td>
<td class="show_main_td_last">
<%--<asp:DropDownList ID="DropDownList3" SelectedValue='<%# DataBinder.Eval( Container, "DataItem.试片失重法" ) %>' Width="80%" runat="server">
<asp:ListItem Value="1" Text="是"></asp:ListItem>
<asp:ListItem Value="0" Text="否"></asp:ListItem>
</asp:DropDownList> --%>
<asp:CheckBox ID="chkSPSZF" Checked='<%# (DataBinder.Eval( Container, "DataItem.试片失重法")).ToString()=="1"?true:false %>' runat="server" />
</td>
<td class="show_main_td_last">电阻探针:</td>
<td class="show_main_td_last">
<%-- <asp:DropDownList ID="DropDownList4" SelectedValue='<%# Bind("电阻探针") %>' Width="80%" runat="server">
<asp:ListItem Value="1" Text="是"></asp:ListItem>
<asp:ListItem Value="0" Text="否"></asp:ListItem>
</asp:DropDownList> --%> <asp:CheckBox ID="chkDZTZ" Checked='<%# (DataBinder.Eval( Container, "DataItem.电阻探针")).ToString()=="1"?true:false %>' runat="server" />
</td>
</tr>
<tr>
<td class="show_main_td_first" >氢探针:</td>
<td class="show_main_td_last">
<asp:CheckBox ID="chkQTZ" Checked='<%# (DataBinder.Eval( Container, "DataItem.氢探针")).ToString()=="1"?true:false %>' runat="server" />
</td>
<td class="show_main_td_last">建点日期:</td>
<td class="show_main_td_last">
<telerik:RadDatePicker ID="RadDatePicker2" DbSelectedDate='<%# DataBinder.Eval( Container, "DataItem.建点日期" ) %>' Width="80%" runat="server" >
<Calendar UseRowHeadersAsSelectors="False" UseColumnHeadersAsSelectors="False" ViewSelectorText="x">
</Calendar>
<DatePopupButton ImageUrl="" HoverImageUrl=""></DatePopupButton>
<DateInput DisplayDateFormat="yyyy-M-d" DateFormat="yyyy-M-d"></DateInput>
</telerik:RadDatePicker>
</td>
</tr>
<tr>
<td class="show_main_td_first" >报废日期:</td>
<td class="show_main_td_last">
<telerik:RadDatePicker ID="RadDatePicker1" DbSelectedDate='<%# DataBinder.Eval( Container, "DataItem.报废日期" ) %>' Width="80%" runat="server" >
<Calendar UseRowHeadersAsSelectors="False" UseColumnHeadersAsSelectors="False" ViewSelectorText="x"></Calendar>
<DatePopupButton ImageUrl="" HoverImageUrl=""></DatePopupButton>
<DateInput DisplayDateFormat="yyyy-M-d" DateFormat="yyyy-M-d"></DateInput>
</telerik:RadDatePicker>
</td>
<td class="show_main_td_last">是否现用:</td>
<td class="show_main_td_last">
<asp:CheckBox ID="CheckBox1" Checked='<%# (DataBinder.Eval( Container, "DataItem.是否现用")).ToString()=="1"?true:false %>' runat="server" />
</td>
</tr>
<tr>
<td class="show_main_td_first" >管道名称:</td>
<td class="show_main_td_last">
<asp:TextBox ID="EFFECTIVEFROMDATE" Text='<%# DataBinder.Eval( Container, "DataItem.管道名称" ) %>' Width="80%" runat="server"></asp:TextBox>
</td>
<td class="show_main_td_first">站场名称:</td>
<td class="show_main_td_last">
<asp:TextBox ID="TextBox2" Text='<%# DataBinder.Eval( Container, "DataItem.场站名称" ) %>' Width="80%" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td class="show_main_td_first" >照片ID:</td>
<td class="show_main_td_last">
<asp:TextBox ID="TextBox1" Text='<%# DataBinder.Eval( Container, "DataItem.照片ID" ) %>' Width="80%" runat="server"></asp:TextBox>
</td>
<td class="show_main_td_last"> </td>
<td class="show_main_td_last"> </td>
</tr>
<tr>
<td class="show_main_td_first">备 注</td>
<td colspan="4" class="show_main_td_last">
<asp:TextBox ID="TextBox3" Text='<%# DataBinder.Eval( Container, "DataItem.备注" ) %>' TextMode="MultiLine" Width="90%" runat="server"></asp:TextBox></td>
</tr>
</table>
<div id="show_main_do">
<asp:Button ID="btnUpdate" Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>'
runat="server" CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'>
</asp:Button>
<asp:Button ID="btnCancel" Text="Cancel" runat="server" CausesValidation="False"
CommandName="Cancel"></asp:Button>
</div>
</div>
</div>
</FormTemplate>
</EditFormSettings>
<CommandItemTemplate>
<div style="padding: 5px 5px;">
监测点信息表操作:
<asp:LinkButton ID="btnEditSelected" runat="server" CommandName="EditSelected" Visible='<%# RadGrid1.EditIndexes.Count == 0 %>'><img style="border:0px;vertical-align:middle;" alt="" src="Images/Edit.gif" />编辑选择项</asp:LinkButton>
<asp:LinkButton ID="btnUpdateEdited" runat="server" CommandName="UpdateEdited" Visible='<%# RadGrid1.EditIndexes.Count > 0 %>'><img style="border:0px;vertical-align:middle;" alt="" src="Images/Update.gif" />更新</asp:LinkButton>
<asp:LinkButton ID="btnCancel" runat="server" CommandName="CancelAll" Visible='<%# RadGrid1.EditIndexes.Count > 0 || RadGrid1.MasterTableView.IsItemInserted %>'><img style="border:0px;vertical-align:middle;" alt="" src="Images/Cancel.gif" />取消编辑</asp:LinkButton>
<asp:LinkButton ID="LinkButton2" runat="server" CommandName="InitInsert" Visible='<%# !RadGrid1.MasterTableView.IsItemInserted %>'><img style="border:0px;vertical-align:middle;" alt="" src="Images/AddRecord.gif" />添加新监测点</asp:LinkButton>
<asp:LinkButton ID="LinkButton3" runat="server" CommandName="PerformInsert" Visible='<%# RadGrid1.MasterTableView.IsItemInserted %>'><img style="border:0px;vertical-align:middle;" alt="" src="Images/Insert.gif" /> Add this Customer</asp:LinkButton>
<asp:LinkButton ID="LinkButton1" OnClientClick="javascript:return confirm('删除所有选择的监测点吗?')"
runat="server" CommandName="DeleteSelected"><img style="border:0px;vertical-align:middle;" alt="" src="Images/Delete.gif" />删除选择监测点</asp:LinkButton>
<asp:LinkButton ID="LinkButton4" runat="server" CommandName="RebindGrid"><img style="border:0px;vertical-align:middle;" alt="" src="Images/Refresh.gif" />刷新监测点列表</asp:LinkButton>
</div>
</CommandItemTemplate>
</MasterTableView>
<ClientSettings>
<Selecting AllowRowSelect="True" EnableDragToSelectRows="True" />
</ClientSettings>
</telerik:RadGrid>
</div>
</td>
</tr>
</table>
<div id="DataSource">
<%-- <sds:SessionDataSource runat="server" ID="SessionDS" ConnectionString="<%$ ConnectionStrings:DBConnectionString %>"
ProviderName="<%$ ConnectionStrings:DBConnectionString.ProviderName %>" ConflictDetection="CompareAllValues"
SelectCommand="SELECT "序号", "作业区", "监测点代号", "监测点名称", "监测点部位", "建点日期", "氢探针", "电阻探针", "试片失重法", "介质", "管线材质", "管线规格", "报废日期", "是否现用", "备注", "管道名称", "场站名称", "照片ID" FROM "监测点名称表""
DeleteCommand="DELETE FROM 监测点名称表 WHERE (监测点代号 = ?)" >
<DeleteParameters>
<asp:Parameter Name="监测点代号" Type="String" />
</DeleteParameters>
</sds:SessionDataSource>--%>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:DBConnectionString %>"
ProviderName="<%$ ConnectionStrings:DBConnectionString.ProviderName %>"
SelectCommand="SELECT "序号", "作业区", "监测点代号", "监测点名称", "监测点部位", "建点日期", "氢探针", "电阻探针", "试片失重法", "介质", "管线材质", "管线规格", "报废日期", "是否现用", "备注", "管道名称", "场站名称", "照片ID" FROM "监测点名称表""
DeleteCommand="DELETE FROM 监测点名称表 WHERE (监测点代号 = :监测点代号)"
UpdateCommand="UPDATE 监测点名称表 SET 序号 = :序号, 作业区 = :作业区, 监测点代号 = :监测点代号, 监测点名称 = :监测点名称, 监测点部位 = :监测点部位, 建点日期 = :建点日期, 氢探针 = :氢探针, 电阻探针 = :电阻探针, 试片失重法 = :试片失重法, 介质 = :介质, 管线材质 = :管线材质, 管线规格 = :管线规格, 报废日期 = :报废日期, 是否现用 = :是否现用, 备注 = :备注, 管道名称 = :管道名称, 场站名称 = :场站名称, 照片ID = :照片ID WHERE (监测点代号 = :监测点代号)">
<UpdateParameters>
<asp:Parameter Name="序号" Type="Int32" />
<asp:Parameter Name="作业区" Type="String" />
<asp:Parameter Name="监测点代号" Type="String" />
<asp:Parameter Name="监测点名称" Type="String" />
<asp:Parameter Name="监测点部位" Type="String" />
<asp:Parameter Name="建点日期" Type="DateTime" />
<asp:Parameter Name="氢探针" Type="Int16" />
<asp:Parameter Name="电阻探针" Type="Int16" />
<asp:Parameter Name="试片失重法" Type="Int16" />
<asp:Parameter Name="介质" Type="String" />
<asp:Parameter Name="管线材质" Type="String" />
<asp:Parameter Name="管线规格" Type="String" />
<asp:Parameter Name="报废日期" Type="DateTime" />
<asp:Parameter Name="是否现用" Type="Int16" />
<asp:Parameter Name="备注" Type="String" />
<asp:Parameter Name="管道名称" Type="String" />
<asp:Parameter Name="场站名称" Type="String" />
<asp:Parameter Name="照片ID" Type="String" />
</UpdateParameters>
<DeleteParameters>
<asp:Parameter Name="监测点代号" Type="String" />
</DeleteParameters>
</asp:SqlDataSource>
</div>
</asp:Content>