How Do use the ImageButton in DataGrid...
How do use the ImageButton in the DataGrid,When click the imageButton,Show the DataGridItem's Every cell with the ImageButton Click row.
You can do as this:
1.custom dagarid TemplateColumn,Add ImageButton into the DataGrid Column[0] and set The ImageButton's CommandName="Edit_User"
2.On the Page_Design show the Properties Chioce the "Event Item" and click Datagrid,and Double-click "Item-click" item command and carete a event "Datagrid Command_Item_Event"
Now you can in the event write
private void Dgd_Result_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
if(e.CommandName=="Edit_User")
{
this.tbx_user_id.Text=e.Item.Cells[1].Text;
this.tbx_user_code.Text=e.Item.Cells[2].Text;
this.tbx_user_name.Text=e.Item.Cells[3].Text;
this.tbx_password.Text=e.Item.Cells[4].Text;
}
}
}
Note: if Not use the custom buttom and you want to click the DataGridItem and show the selectDatagridItem every cell on the textbox ,You can do as this:
private void Dgd_Result_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
if(e.CommandName=="Edit_User")
{
this.tbx_user_id.Text=e.Item.Cells[1].Text;
this.tbx_user_code.Text=e.Item.Cells[2].Text;
this.tbx_user_name.Text=e.Item.Cells[3].Text;
this.tbx_password.Text=e.Item.Cells[4].Text;
}
}
}