Hello Steven Cheng[MSFT],
Hi Rlaw,
Welcome to ASPNET newsgroup. From your description, you are
populating some datas in a webform datagrid, and the datagrid is
always in Editmode so that the user can entry new value or modify the
exsitn datas in the grid's cells(textboxes). Since you set those entry
fields to be autopostback, you found the page will focus on the cell
being edited previously after post back, and you're wondering how to
make the focus auto went to the next cell , yes?
Yes this is totally correct!!
AS for this question, I'm not sure how you define your datagrid's
template columns and bind the data with the textboxes(also , the
autopostback things). Would you provide me some code snippet so that I
can get a detailed view ?
Here is the code for the datagrid, I believe thats the snippet you're looking
for:
<CODE>
<div style="OVERFLOW-Y: scroll; Z-INDEX: 101; LEFT: 136px; OVERFLOW-X: scroll;
WIDTH: 737px; POSITION: absolute; TOP: 387px; HEIGHT: 298px">
<asp:datagrid id="dtgClaimsDetail" runat="server" Font-Size="8pt" Font-Names="Verdana"
Width="1373px"
BackColor="White" BorderStyle="None" ForeColor="Black" AutoGenerateColumns="False"
BorderColor="#DEDFDE" BorderWidth="1px" CellPadding="4" GridLines="Vertical">
<FooterStyle BackColor="#CCCC99"></FooterStyle>
<SelectedItemStyle Font-Bold="True" ForeColor="White" BackColor="#CE5D5A"></SelectedItemStyle>
<AlternatingItemStyle BackColor="White"></AlternatingItemStyle>
<ItemStyle BackColor="#CCCD94"></ItemStyle>
<HeaderStyle Font-Bold="True" ForeColor="#49637A" BackColor="#DAD5D2"></HeaderStyle>
<Columns>
<asp:EditCommandColumn Visible="False" ButtonType="LinkButton" UpdateText="Update"
CancelText="Cancel"
EditText="Edit"></asp:EditCommandColumn>
<asp:TemplateColumn HeaderText="Claim Line<br>Item">
<ItemTemplate>
<asp:Label id=lblClaimLineItem runat="server" Font-Names="Verdana" Font-Size="8pt"
Text='<%# DataBinder.Eval(Container, "DataItem.CLAIM_LINE_ITEM") %>'>
</asp:Label>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Site Id">
<HeaderStyle ForeColor="Red"></HeaderStyle>
<ItemTemplate>
<asp
ropDownList id=ddlLinesSiteId AutoPostBack="true" onSelectedIndexChanged="dtgRowChanged"
Font-Names="Verdana" Font-Size="8pt" Runat="server" datavaluefield="SITE_ID"
datatextfield="NAME" datamember="SiteIDs" datasource="<%# DataSet7 %>">
</asp
ropDownList>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Dept Id">
<HeaderStyle ForeColor="Red"></HeaderStyle>
<ItemTemplate>
<asp
ropDownList id=ddlDeptID Font-Size="8pt" Font-Names="Verdana" AutoPostBack="true"
onSelectedIndexChanged="dtgRowChanged" datasource="<%# DataSet6 %>" datamember="DeptIDs"
datatextfield="SHORT_TEXT" datavaluefield="MASTER_CODE_VAL" Runat="server">
</asp
ropDownList>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Reason">
<ItemTemplate>
<asp:TextBox id=txtdtgReason runat="server" Font-Size="8pt" Font-Names="Verdana"
Text='<%# DataBinder.Eval(Container, "DataItem.SHORT_TEXT") %>' AutoPostBack="true"
onTextChanged="dtgRowChanged" TextMode="MultiLine">
</asp:TextBox>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Qty">
<HeaderStyle ForeColor="Red"></HeaderStyle>
<ItemTemplate>
<asp:TextBox id=txtdtgQty runat="server" Font-Size="8pt" Font-Names="Verdana"
Width="73px" Text='<%# DataBinder.Eval(Container, "DataItem.QTY") %>' AutoPostBack="true"
onTextChanged="dtgQtyPriceChanged">
</asp:TextBox>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="UOM Code">
<HeaderStyle ForeColor="Red"></HeaderStyle>
<ItemTemplate>
<asp
ropDownList id=ddlLinesUOM Font-Names="Verdana" Font-Size="8pt" AutoPostBack="true"
onSelectedIndexChanged="dtgRowChanged" Runat="server" datavaluefield="MASTER_CODE_VAL"
datatextfield="SHORT_TEXT" datamember="UOMCodes" datasource="<%# DataSet8
%>">
</asp
ropDownList>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Price">
<HeaderStyle ForeColor="Red"></HeaderStyle>
<ItemTemplate>
<asp:TextBox id=txtdtgPrice Font-Names="Verdana" Font-Size="8pt" runat="server"
Text='<%# DataBinder.Eval(Container, "DataItem.PRICE") %>' Width="73px" AutoPostBack="true"
onTextChanged="dtgQtyPriceChanged">
</asp:TextBox>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Claim Amount">
<HeaderStyle ForeColor="Red"></HeaderStyle>
<ItemTemplate>
<asp:TextBox id=txtdtgClaimAmt Font-Names="Verdana" Font-Size="8pt" runat="server"
Text='<%# DataBinder.Eval(Container, "DataItem.CLAIM_AMT") %>' Width="73px"
AutoPostBack="true" onTextChanged="dtgRowChanged">
</asp:TextBox>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Supp Invt Unit Id">
<ItemTemplate>
<asp:TextBox id=txtdtgSuppInvtUnitId Font-Names="Verdana" Font-Size="8pt"
runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.SUPP_INVT_UNIT_ID")
%>' Width="73px" AutoPostBack="true" onTextChanged="dtgRowChanged">
</asp:TextBox>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Mfg Ord No">
<ItemTemplate>
<asp:TextBox id=txtdtgMfgOrdNo Font-Names="Verdana" Font-Size="8pt" runat="server"
Text='<%# DataBinder.Eval(Container, "DataItem.MFG_ORD_NO") %>' Width="73px"
AutoPostBack="True" ontextchanged="dtgMfgChanged">
</asp:TextBox>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Fin Style Id">
<ItemTemplate>
<asp:TextBox id=txtdtgFinStyleId Font-Names="Verdana" Font-Size="8pt" runat="server"
Text='<%# DataBinder.Eval(Container, "DataItem.FIN_STYLE_ID") %>' Width="73px"
AutoPostBack="true" onTextChanged="dtgRowChanged">
</asp:TextBox>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Comment">
<ItemTemplate>
<asp:TextBox id=txtdtgComment Font-Names="Verdana" Font-Size="8pt" runat="server"
Text='<%# DataBinder.Eval(Container, "DataItem.COMMENT") %>' AutoPostBack="true"
TextMode="MultiLine" onTextChanged="dtgRowChanged">
</asp:TextBox>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Created Dttm">
<ItemTemplate>
<asp:Label Font-Names="Verdana" Font-Size="8pt" runat="server" Text='<%#
DataBinder.Eval(Container, "DataItem.ROW_CREATED_DTTM") %>' ID="Label1">
</asp:Label>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Created By">
<ItemTemplate>
<asp:Label Font-Names="Verdana" Font-Size="8pt" runat="server" Text='<%#
DataBinder.Eval(Container, "DataItem.ROW_CREATED_BY_USER_ID") %>' ID="Label2">
</asp:Label>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Updated Dttm">
<ItemTemplate>
<asp:Label Font-Names="Verdana" Font-Size="8pt" runat="server" Text='<%#
DataBinder.Eval(Container, "DataItem.ROW_UPDATED_DTTM") %>' ID="Label3">
</asp:Label>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Updated By">
<ItemTemplate>
<asp:Label Font-Names="Verdana" Font-Size="8pt" runat="server" Text='<%#
DataBinder.Eval(Container, "DataItem.ROW_UPDATED_BY_USER_ID") %>' ID="Label4">
</asp:Label>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
<PagerStyle NextPageText="|Next 10" PrevPageText="Prev 10|" HorizontalAlign="Right"
ForeColor="Black"
BackColor="#F7F7DE" Mode="NumericPages"></PagerStyle>
</asp:datagrid>
</div>
Generally the webform datagrid should be used to display datas and in
edit mode, only one gridrow is under editing. Also, the TextBoxes are
not autopostback by default, are you using Custom TemplateColumn ?
Normally yes I would only have one gridrow under editing however, in this
case the design calls for all rows to be in edit mode without the user having
to do anything. SIGH. Yes, I am using the Custom TemplateColumn.
As for set the focus on control, we can make use the clientside 's
"focus()" jscript , and at serverside, we can get a control's
clientside DOM id via its ClientID property, I think this is a
potential approach. So if you can provide me some code snippet , I can
have a further look into it .
Thanks,
Steven Cheng
Microsoft Online Support
Get Secure!
www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
THANKS for the quick response and the help!!