2
我想在GridView中拆分顯示和更新日期時間。我如何在SqlDataSource的UpdateParameters中重新組合它們?在C#中的DateTime更新字段GridView
例如
<asp:SqlDataSource ID="uxTravelTripMeetingDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:MGO %>"
ProviderName="<%$ ConnectionStrings:MGO.ProviderName %>"
SelectCommand="select * from v_travel_meeting t where travel_trip_id = :travel_trip_id"
UpdateCommand="update travel_prospect set person = :person, meeting_date = :meeting_date where prospect_id = :prospect_id and travel_trip_id = :travel_trip_id "
<SelectParameters>
<asp:QueryStringParameter Name="travel_trip_id" QueryStringField="id" />
</SelectParameters>
<UpdateParameters>
<asp:Parameter Name="person" />
<asp:Parameter Name="prospect_id" />
<asp:Parameter Name="travel_trip_id"/>
<asp:Parameter Name="meeting_date" Type="DateTime" />
</UpdateParameters>
</asp:SqlDataSource>
<asp:GridView ID="uxTravelTripMeetingGridView" runat="server"
DataSourceID="uxTravelTripMeetingDataSource" AutoGenerateColumns="False"
DataKeyNames="travel_trip_id,prospect_id">
<Columns>
<asp:CommandField ShowEditButton="True" />
<asp:TemplateField HeaderText="Prospect">
<ItemTemplate>
<a href="something.aspx?prospectid=<%# Eval("prospect_id") %>&height=500&width=600" title="caption" class="thickbox" ><%# Eval("prospect_name")%>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="person" HeaderText="Person" />
<asp:TemplateField>
<ItemTemplate>
<asp:Label ID="Label3" runat="server"
Text='<%# Bind("meeting_date", "{0:d}") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="TextBox3" runat="server"
Text='<%# Bind("meeting_date", "{0:d}") %>' />
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:Label ID="Label3" runat="server"
Text='<%# Bind("Meeting_time") %>'></asp:Label>
<asp:Label ID="Label4" runat="server"
Text='<%# Bind("Meeting_am_pm") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:ObjectDataSource ID="ds15Min" runat="server" OldValuesParameterFormatString="original_{0}"
SelectMethod="DDLFifteenMin" TypeName="App" />
<asp:DropDownList ID="DropDownList2" runat="server"
DataSourceID="ds15Min" DataTextField="time" DataValueField="display"
SelectedValue='<%# Bind("meeting_date","{0:t}") %>' >
<asp:ListItem Value=" "> </asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
謝謝!
這種工作...我使用Oracle,但我可以自己翻譯DATEADD [to_date(To_Char(date)||''||:time,'DD-MON-YY HH:MI AM') ],唯一不清楚的是如何將gridview中的參數綁定到組成的參數名稱。 – Lloyd 2009-08-28 20:15:30
唯一不清楚的是如何將gridview中的參數綁定到從原始字段分離的參數。 – Lloyd 2009-08-28 21:58:53