程式範例
//Default.aspx 前端程式
<asp:GridView ID="GridView1" runat="server"
onrowcommand="GridView_RowCommand"
onrowdatabound="GridView_RowDataBound">
<Columns>
<asp:TemplateField HeaderText="Button1" SortExpression="Button">
<ItemTemplate>
<asp:Button ID="Button" runat="server" Text="加入"
CommandName="ButtonAdd"
CommandArgument='<%# Container.DataItemIndex %>'/>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
//Default.aspx.cs 後端程式
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "ButtonAdd")
{
//取得按下按鈕的那列的索引
int index = Convert.ToInt32(e.CommandArgument);
TextBox1.Text = GridView1.Rows[index].Cells[1].Text;
TextBox2.Text = GridView1.Rows[index].Cells[2].Text;
TextBox3.Text = GridView1.Rows[index].Cells[3].Text;
}
}
<asp:GridView ID="GridView1" runat="server"
onrowcommand="GridView_RowCommand"
onrowdatabound="GridView_RowDataBound">
<Columns>
<asp:TemplateField HeaderText="Button1" SortExpression="Button">
<ItemTemplate>
<asp:Button ID="Button" runat="server" Text="加入"
CommandName="ButtonAdd"
CommandArgument='<%# Container.DataItemIndex %>'/>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
//Default.aspx.cs 後端程式
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "ButtonAdd")
{
//取得按下按鈕的那列的索引
int index = Convert.ToInt32(e.CommandArgument);
TextBox1.Text = GridView1.Rows[index].Cells[1].Text;
TextBox2.Text = GridView1.Rows[index].Cells[2].Text;
TextBox3.Text = GridView1.Rows[index].Cells[3].Text;
}
}
Playtech and Binance - KADANG PICTAR
回覆刪除Playtech and Binance are two of the leading kadangpintar casino หารายได้เสริม operators 인카지노 in the world, with Binance's position as the leading technology company in the