在gridview中編輯時, 輸入某一欄資料, 要帶出另一欄資料(草稿)
在gridview中編輯時,
輸入某一欄資料, 要帶出另一欄資料, 要在哪個EVENT裡寫?
EX. 在第一欄身份證ID輸入後, 自動帶出第二欄的姓名...
網頁:
<asp:GridView ID="gvFundTradeS" runat="server" AutoGenerateColumns="False" AllowPaging="True"
BorderColor="#3366CC" BorderStyle="None" BorderWidth="0px" BackColor="#3366CC"
CellSpacing="1" CellPadding="4" OnRowCancelingEdit="gvFundTradeS_RowCancelingEdit"
OnRowEditing="gvFundTradeS_RowEditing" OnRowCommand="gvFundTradeS_RowCommand"
OnRowDataBound="gvFundTradeS_RowDataBound" AllowSorting="True" ShowFooter="True"
OnRowDeleting="gvFundTradeS_RowDeleting"
OnPageIndexChanging="gvFundTradeS_PageIndexChanging" OnSelectedIndexChanged="gvFundTradeS_SelectedIndexChanged" OnRowUpdating="gvFundTradeS_RowUpdating">
<RowStyle HorizontalAlign="Center" ForeColor="#003399" VerticalAlign="Middle" BackColor="White" />
<HeaderStyle Font-Bold="True" HorizontalAlign="Center" ForeColor="#CCCCFF" VerticalAlign="Middle"
BackColor="#003399" />
<FooterStyle ForeColor="#003399" BackColor="#99CCCC" />
<asp:TemplateField HeaderText="客戶帳號">
<ItemTemplate>
<asp:Label ID="lblCustomerId" runat="server" Text='<%# Bind("customer_id") %>'></asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:TextBox ID="add_CustomerId" runat="server" MaxLength="11" Width="85px" OnTextChanged="add_CustomerId_TextChanged"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="客戶姓名">
<ItemTemplate>
<asp:Label ID="lblCustomerName" runat="server" Text='<%# Bind("name") %>'></asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:TextBox ID="add_CustomerName" runat="server" Enabled="False"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
程式碼:
protected void gvFundTradeS_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Footer)
{
#region 新增欄位
GetUpBroker((DropDownList)e.Row.Cells[11].FindControl("add_TrandferUpbroker"));
((TextBox)e.Row.Cells[12].FindControl("add_TransDate")).Text = DateTime.Now.Date.ToString("yyyy/MM/dd")
((TextBox)e.Row.Cells[13].FindControl("add_AgentId")).Text = Session["BranchId"].ToString() + Session["AgentId"].ToString();
((TextBox)e.Row.Cells[0].FindControl("add_CustomerId")).AutoPostBack = true;
#endregion
}
}
protected void add_CustomerId_TextChanged(object sender, EventArgs e)
{
設定customer_name的值;
}