有没有办法做到这一点。假设用户在 datagridview 的更新行中。他们只想按回车键并触发更新按钮,而不考虑他们在行中的位置。有没有办法做到这一点?我曾尝试弄乱标签顺序,但我可以将更新标签留在标签顺序之外,并在用户按 Enter 时使其更新吗?
<%@ Assembly src="porch_samples.ascx.cs" %>
<%@ Control Language="c#" AutoEventWireup="false" Codebehind="porch_samples.ascx.cs" Inherits="porch_samples.hendrix" TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %>
<%@ Register Assembly="obout_ComboBox" Namespace="Obout.ComboBox" TagPrefix="cc1" %>
<script type="text/javascript">
</script>
<div style="OVERFLOW: auto; LEFT: -1px; WIDTH: 1320px; POSITION: relative; HEIGHT: 550px; BACKGROUND-COLOR: #FFFFFF; top: 0px;">
<% // drop down lists %>
<asp:DropDownList ID="listQcId" style="Z-INDEX: 159; LEFT:95px; POSITION: absolute; TOP: 5px;"
runat="server" DataSourceID="fill_qc_id_grid"
DataTextField="qc_id" DataValueField="qc_id"
AppendDataBoundItems="True" AutoPostBack="True">
<asp:ListItem Selected ="True" Text="" Value ="">(Select)</asp:ListItem>
</asp:DropDownList>
<asp:SqlDataSource ID="fill_qc_id_grid" runat="server"
ConnectionString="<%$ ConnectionStrings:AADConnectionString %>" SelectCommand="select distinct fta.qc_id from t_ap_qc_master_fta fta
inner join t_ap_qc_master qcm on qcm.qc_id = fta.qc_id
where
isnull(qcm.qc_complete,'N') = 'N'
and qcm.qc_type like 'Receiving'"></asp:SqlDataSource>
<asp:GridView ID="grdPanel" runat="server" AutoGenerateColumns="False" style= "Z-INDEX: 159; LEFT:10px; POSITION: absolute; TOP: 40px;"
CellPadding="4" DataSourceID="progress" EnableModelValidation="True"
Font-Size="Smaller" ForeColor="#333333" GridLines="None"
DataKeyNames="qc_id,Smpl_ID">
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:TemplateField ShowHeader="False">
<EditItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True"
CommandName="Update" TabIndex="5" Text="Update"></asp:LinkButton>
<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False"
CommandName="Cancel" Text="Cancel"></asp:LinkButton>
</EditItemTemplate>
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False"
CommandName="Edit" Text="Edit"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Smpl_ID" SortExpression="Smpl_ID">
<EditItemTemplate>
<asp:Label ID="grdFruit_id" runat="server" Text='<%# Eval("Smpl_ID") %>'></asp:Label>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("Smpl_ID") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Size" SortExpression="Size">
<EditItemTemplate>
<asp:Label ID="grdSize" runat="server" Text='<%# Bind("Size", "{0}") %>'></asp:Label>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("Size") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Grade" SortExpression="Grade">
<EditItemTemplate>
<asp:DropDownList ID="grdddlGrade" runat="server" AppendDataBoundItems="True"
SelectedValue='<%# Bind("Grade") %>' TabIndex="1" AutoPostBack="True">
<asp:ListItem Value="">(Select)</asp:ListItem>
<asp:ListItem Value="AA">AA</asp:ListItem>
<asp:ListItem Value="A">A</asp:ListItem>
<asp:ListItem Value="B">B</asp:ListItem>
<asp:ListItem Value="C">C</asp:ListItem>
<asp:ListItem Value="F">F</asp:ListItem>
<asp:ListItem Value="UF">UF</asp:ListItem>
<asp:ListItem Value="USXF">USXF</asp:ListItem>
<asp:ListItem Value="USXFB">USXFB</asp:ListItem>
<asp:ListItem Value="USXFP">USXFP</asp:ListItem>
<asp:ListItem Value="USXFR">USXFR</asp:ListItem>
<asp:ListItem Value="CULL">CULL</asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label3" runat="server" Text='<%# Bind("Grade") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Color_Score" SortExpression="Color_Score">
<EditItemTemplate>
<asp:DropDownList ID="grdColor" runat="server" AppendDataBoundItems="True"
DataSourceID="color" DataTextField="score" DataValueField="rec_id"
SelectedValue='<%# Bind("color") %>' TabIndex="2">
<asp:ListItem Value="0">(Select)</asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label7" runat="server" Text='<%# Bind("Color_Score") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Bkgrd" SortExpression="Bkgrd">
<EditItemTemplate>
<asp:DropDownList ID="grdbkgrd" runat="server"
SelectedValue='<%# Bind("Bkgrd") %>' TabIndex="3">
<asp:ListItem Value="">(Select)</asp:ListItem>
<asp:ListItem Value="Green">Green</asp:ListItem>
<asp:ListItem Value="Green/Yellow">Green/Yellow</asp:ListItem>
<asp:ListItem Value="Yellow/Cream">Yellow/Cream</asp:ListItem>
<asp:ListItem Value="Cream">Cream</asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label8" runat="server" Text='<%# Bind("Bkgrd") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Starch" SortExpression="Starch">
<EditItemTemplate>
<asp:DropDownList ID="grdStarch" runat="server"
SelectedValue='<%# Bind("Starch", "{0:N}") %>' TabIndex="4">
<asp:ListItem Value="">(Select)</asp:ListItem>
<asp:ListItem Value="0.0">0.0</asp:ListItem>
<asp:ListItem Value="1.0">1.0</asp:ListItem>
<asp:ListItem Value="1.5">1.5</asp:ListItem>
<asp:ListItem Value="1.8">1.8</asp:ListItem>
<asp:ListItem Value="2.0">2.0</asp:ListItem>
<asp:ListItem Value="2.2">2.2</asp:ListItem>
<asp:ListItem Value="2.5">2.5</asp:ListItem>
<asp:ListItem Value="3.0">3.0</asp:ListItem>
<asp:ListItem Value="3.5">3.5</asp:ListItem>
<asp:ListItem Value="4.0">4.0</asp:ListItem>
<asp:ListItem Value="4.5">4.5</asp:ListItem>
<asp:ListItem Value="5.0">5.0</asp:ListItem>
<asp:ListItem Value="5.0">5.5</asp:ListItem>
<asp:ListItem Value="6.0">6.0</asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label4" runat="server" Text='<%# Bind("Starch") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="def_id_1" HeaderText="def_id_1"
SortExpression="def_id_1" Visible="False" />
<asp:TemplateField HeaderText="Def_1" SortExpression="Def_1">
<EditItemTemplate>
<asp:DropDownList ID="grdddldef1" runat="server"
SelectedValue='<%# Bind("def_id_1") %>' AppendDataBoundItems="True"
AutoPostBack="True" DataSourceID="defects" DataTextField="description"
DataValueField="defect_id">
<asp:ListItem Value="0">(Select)</asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label5" runat="server" Text='<%# Bind("Def_1") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="def_id_2" HeaderText="def_id_2"
SortExpression="def_id_2" Visible="False" />
<asp:TemplateField HeaderText="Def_2" SortExpression="Def_2">
<EditItemTemplate>
<asp:DropDownList ID="grdDefid2" runat="server" DataSourceID="defects"
DataTextField="description" DataValueField="defect_id"
SelectedValue='<%# Bind("def_id_2") %>' AppendDataBoundItems="True">
<asp:ListItem Value="0">(Select)</asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label6" runat="server" Text='<%# Bind("Def_2") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="color" HeaderText="color" SortExpression="color"
Visible="False" />
<asp:BoundField DataField="app_def_id_1" HeaderText="app_def_id_1"
SortExpression="app_def_id_1" Visible="False" />
<asp:TemplateField HeaderText="App_1" SortExpression="App_1">
<EditItemTemplate>
<asp:DropDownList ID="grdddlapp1" runat="server" AppendDataBoundItems="True"
DataSourceID="app_defect" DataTextField="description"
DataValueField="defect_id" SelectedValue='<%# Bind("app_def_id_1") %>'>
<asp:ListItem Value="0">(Select)</asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label9" runat="server" Text='<%# Bind("App_1") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Rate_1" SortExpression="Rate_1">
<EditItemTemplate>
<asp:DropDownList ID="grdRate1" runat="server"
SelectedValue='<%# Bind("Rate_1") %>'>
<asp:ListItem Value="">(Select)</asp:ListItem>
<asp:ListItem>Initial</asp:ListItem>
<asp:ListItem>Moderate</asp:ListItem>
<asp:ListItem>Severe</asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label10" runat="server" Text='<%# Bind("Rate_1") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="app_def_id_2" HeaderText="app_def_id_2"
SortExpression="app_def_id_2" Visible="False" />
<asp:TemplateField HeaderText="App_2" SortExpression="App_2">
<EditItemTemplate>
<asp:DropDownList ID="grdddlapp2" runat="server" AppendDataBoundItems="True"
DataSourceID="app_defect" DataTextField="description"
DataValueField="defect_id" SelectedValue='<%# Bind("app_def_id_2") %>'>
<asp:ListItem Value="0">(Select)</asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label11" runat="server" Text='<%# Bind("App_2") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Rate_2" SortExpression="Rate_2">
<EditItemTemplate>
<asp:DropDownList ID="grdapprate2" runat="server" AppendDataBoundItems="True"
SelectedValue='<%# Bind("Rate_2") %>'>
<asp:ListItem Value="">(Select)</asp:ListItem>
<asp:ListItem Value="Initial">Initial</asp:ListItem>
<asp:ListItem Value="Moderate">Moderate</asp:ListItem>
<asp:ListItem Value="Severe">Severe</asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label12" runat="server" Text='<%# Bind("Rate_2") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="WC" SortExpression="WC">
<EditItemTemplate>
<asp:DropDownList ID="grdWC" runat="server"
SelectedValue='<%# Bind("WC") %>'>
<asp:ListItem>0</asp:ListItem>
<asp:ListItem>1</asp:ListItem>
<asp:ListItem>2</asp:ListItem>
<asp:ListItem>3</asp:ListItem>
<asp:ListItem>4</asp:ListItem>
<asp:ListItem>5</asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label13" runat="server" Text='<%# Bind("WC") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="IB" SortExpression="IB">
<EditItemTemplate>
<asp:DropDownList ID="grdIB" runat="server"
SelectedValue='<%# Bind("IB") %>'>
<asp:ListItem>0</asp:ListItem>
<asp:ListItem>1</asp:ListItem>
<asp:ListItem>2</asp:ListItem>
<asp:ListItem>3</asp:ListItem>
<asp:ListItem>4</asp:ListItem>
<asp:ListItem>5</asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label14" runat="server" Text='<%# Bind("IB") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="qc_id" SortExpression="qc_id" Visible="False">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("qc_id") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label15" runat="server" Text='<%# Bind("qc_id") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<EditRowStyle BackColor="#99CCFF" HorizontalAlign="Center" />
<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" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
</asp:GridView>
<asp:SqlDataSource ID="upper_level_grid" runat="server"
ConnectionString="<%$ ConnectionStrings:AADConnectionString %>" SelectCommand="
select
convert(varchar,qcm.qc_date,101) as 'Date',
map.storage as 'Storage',
var.description as 'Variety',
map.room as 'Room' ,
grw.grower_id+' - '+grw.grower_name as 'Grower'
from t_ap_qc_master qcm
inner join t_bin_master_ap map on map.master_ticket_id = qcm.master_ticket_id
inner join t_variety var on var.variety_id = map.variety_id
inner join t_grower grw on grw.grower_id = map.grower_id
where qcm.qc_id = @qc_id ">
<SelectParameters>
<asp:ControlParameter ControlID="listQcId" Name="qc_id"
PropertyName="SelectedValue" />
</SelectParameters>
</asp:SqlDataSource>
<asp:SqlDataSource ID="fruit_id" runat="server"
ConnectionString="<%$ ConnectionStrings:AADConnectionString %>" SelectCommand="select top (1) fruit_id as 'Fruit ID'
from t_ap_qc_detail
where qc_id = @qc_id and grade is null ">
<SelectParameters>
<asp:ControlParameter ControlID="listQcId" Name="qc_id"
PropertyName="SelectedValue" />
</SelectParameters>
</asp:SqlDataSource>
<asp:SqlDataSource ID="fill_size" runat="server"
ConnectionString="<%$ ConnectionStrings:AADConnectionString %>" SelectCommand="SELECT
top (1)
qcd.size_name
FROM t_ap_qc_master_fta qcf
inner JOIN t_ap_qc_detail qcd ON qcf.qc_id = qcd.qc_id and qcf.fruit_id = qcd.fruit_id
WHERE qcf.qc_id = @qc_id and qcd.grade is null ">
<SelectParameters>
<asp:ControlParameter ControlID="listQcId" Name="qc_id"
PropertyName="SelectedValue" />
</SelectParameters>
</asp:SqlDataSource>
<asp:SqlDataSource ID="color" runat="server"
ConnectionString="<%$ ConnectionStrings:AADConnectionString %>" SelectCommand="SELECT rec_id, score FROM t_ap_qc_color_score
WHERE score_id =
(CASE WHEN ((SELECT variety_id FROM t_bin_master_ap
WHERE master_ticket_id = (select master_ticket_id from t_ap_qc_master
WHERE qc_id = @qc_id)) IN ('09','1J','1P','4E','4F','4I'))
THEN '2'
WHEN ((SELECT variety_id FROM t_bin_master_ap
WHERE master_ticket_id = (select master_ticket_id from t_ap_qc_master
WHERE qc_id = @qc_id)) IN ('6X','6Z'))
THEN '3'
ELSE '1'
END)
and type = 'Coverage' and status = 'A'">
<SelectParameters>
<asp:ControlParameter ControlID="listQcId" Name="qc_id"
PropertyName="SelectedValue" />
</SelectParameters>
</asp:SqlDataSource>
<asp:SqlDataSource ID="defects" runat="server"
ConnectionString="<%$ ConnectionStrings:AADConnectionString %>" SelectCommand="select defect_id, description
from t_defect where
/*type = 'DEFECT' and */
inv_cat = 'AP' and status = 'A'
and defect_id IN ('41','11','42','36',
'19','187','186','26','46','20','10','40',
'1','224','89','83','3','14','37','212',
'213','191','2','38','83','226','230','232')
order by description"></asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:AADConnectionString %>" SelectCommand="select defect_id, description
from t_defect where
/*type = 'DEFECT' and */
inv_cat = 'AP' and status = 'A'
and defect_id IN ('41','11','42','36',
'19','187','186','26','46','20','10','40',
'1','224','89','83','3','14','37','212',
'213','191','2','38','83','226','230','232')
order by description"></asp:SqlDataSource>
<asp:SqlDataSource ID="app_defect" runat="server"
ConnectionString="<%$ ConnectionStrings:AADConnectionString %>" SelectCommand="select defect_id, description
from t_defect
where inv_cat = 'AP' and status = 'A'
and defect_id IN ('15','79','80','77','88','4','39')
order by description"></asp:SqlDataSource>
<asp:SqlDataSource ID="app_defect0" runat="server"
ConnectionString="<%$ ConnectionStrings:AADConnectionString %>" SelectCommand="select defect_id, description
from t_defect
where inv_cat = 'AP' and status = 'A'
and defect_id IN ('15','79','80','77','88','4','39')
order by description"></asp:SqlDataSource>
<asp:SqlDataSource ID="update" runat="server"
ConnectionString="<%$ ConnectionStrings:AADConnectionString %>" SelectCommand="Select
fruit_id
from t_ap_qc_detail
where qc_id = @qc_id
and starch is not null">
<SelectParameters>
<asp:ControlParameter ControlID="listQcId" Name="qc_id"
PropertyName="SelectedValue" />
</SelectParameters>
</asp:SqlDataSource>
<% // Lables as description %>
<asp:Label id="lblQcID" style="Z-INDEX: 159; LEFT: 5px; POSITION: absolute; TOP: 5px; HEIGHT: 24px; "
runat="server" Font-Names="Calibri">Select QC-ID:</asp:Label>
<% // Text Boxes %>
<% // Buttons%><% // Data Grids %>
<asp:SqlDataSource ID="progress" runat="server"
ConnectionString="<%$ ConnectionStrings:AADConnectionString %>"
SelectCommand="SELECT DISTINCT
convert(int,qcd.fruit_id) as Smpl_ID,
qcd.size_name as Size,
qcd.grade as Grade,
cs.score as 'Color_Score',
qcd.background as 'Bkgrd',
convert(varchar,convert(decimal(15,1),qcd.starch)) as Starch,
isnull(qcd.def_id_1,'0') as def_id_1,
def1.description as 'Def_1',
isnull(qcd.def_id_2,'0') as def_id_2,
def2.description as Def_2,
isnull(qcd.color,'0') as color,
isnull(qcd.app_def_id_1,'0') as app_def_id_1,
def3.description as App_1,
qcd.app_rating_1 as Rate_1,
isnull(qcd.app_def_id_2,'0') as app_def_id_2,
def4.description as App_2,
qcd.app_rating_2 as Rate_2,
--qcf.color,
isnull(qcd.watercore,'0') as WC,
isnull(qcd.internal_browning,'0') as IB,
qcd.qc_id as qc_id
--qcd.status
FROM t_ap_qc_master_fta qcf
LEFT OUTER JOIN t_ap_qc_master qcm (NOLOCK) on qcm.qc_id = qcf.qc_id
LEFT OUTER JOIN t_ap_qc_detail qcd ON qcf.qc_id = qcd.qc_id and qcf.fruit_id = qcd.fruit_id
LEFT OUTER JOIN t_defect def1 ON def1.defect_id = qcd.def_id_1
LEFT OUTER JOIN t_defect def2 ON def2.defect_id = qcd.def_id_2
LEFT OUTER JOIN t_defect def3 ON def3.defect_id = qcd.app_def_id_1
LEFT OUTER JOIN t_defect def4 ON def4.defect_id = qcd.app_def_id_2
LEFT OUTER JOIN t_ap_qc_color_score cs (NOLOCK) on cs.rec_id = qcd.color
WHERE qcd.qc_id = @qc_id
ORDER BY qcd.fruit_id"
UpdateCommand="update t_ap_qc_detail
set
fruit_id = @Smpl_ID,
size_name = @Size,
[grade] = @Grade,
[def_id_1] = @def_id_1,
def_id_2 = @def_id_2,
app_def_id_1= @app_def_id_1,
app_rating_1 = @Rate_1,
app_def_id_2 = @app_def_id_2,
app_rating_2 = @Rate_2,
color = @color,
background = @Bkgrd,
watercore = @WC,
internal_browning = @IB,
starch = @Starch
where qc_id = @qc_id and fruit_id = @Smpl_ID" >
<SelectParameters>
<asp:ControlParameter ControlID="listQcId" Name="qc_id"
PropertyName="SelectedValue" />
</SelectParameters>
<UpdateParameters>
<asp:Parameter Name="Smpl_ID" Type="Int16"/>
<asp:Parameter Name="Size" Type="Int32" />
<asp:Parameter Name="Grade" Type="String"/>
<asp:Parameter Name="def_id_1" Type="Int32" />
<asp:Parameter Name="def_id_2" Type="Int32" />
<asp:Parameter Name="app_def_id_1" Type="Int32" />
<asp:Parameter Name="Rate_1" Type="String"/>
<asp:Parameter Name="app_def_id_2" Type="Int32" />
<asp:Parameter Name="Rate_2" Type="String" />
<asp:Parameter Name="color" Type="Int32" />
<asp:Parameter Name="Bkgrd" type="String"/>
<asp:Parameter Name="WC" Type="String" />
<asp:Parameter Name="IB" Type="Int32" />
<asp:Parameter Name="Starch" Type="String" />
<asp:Parameter Name="qc_id" Type="Int16" />
<asp:Parameter Name="Fruit_ID"></asp:Parameter>
</UpdateParameters>
</asp:SqlDataSource>
</div>