I want edit a Grid View using code behind and classes, without datasource controls. I wrote this code:
private void ZaladujGridView()
{
GridView2.DataSource = EuroPilka.terminarzLiga.wyswietlTerminarz();
GridView2.DataBind();
}
protected void GridView2_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "EditRow")
{
int rowIndex = ((GridViewRow)((LinkButton)e.CommandSource).NamingContainer).RowIndex;
GridView2.EditIndex = rowIndex;
ZaladujGridView();
}
else if (e.CommandName == "UpdateRow")
{
int rowIndex = ((GridViewRow)((LinkButton)e.CommandSource).NamingContainer).RowIndex;
int id = Convert.ToInt32(e.CommandArgument);
string druzyna = ((TextBox).GridView2.Rows[rowIndex].FindControl("TextBox1")).Text;
EuroPilka.terminarzLiga.aktualizujTerminarz(id, druzyna);
GridView2.EditIndex = -1;
ZaladujGridView();
}
}
but in line
string druzyna = ((TextBox).GridView2.Rows[rowIndex].FindControl("TextBox1")).Text;
I've got error: "Textbox is a type but used like variable". Could You tell what is wrong with that ?
There is a dot here:
((TextBox).
I think it should just be:
((TextBox) GridView2.Rows[rowIndex].FindControl("TextBox1"))
Because you're casting.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.