Jurioli / Blazor.WebForm.Components

ASP.NET Web Forms System.Web.UI.WebControls Razor Components For Blazor WebAssembly, Blazor Hybrid, Blazor Server.
MIT License
44 stars 9 forks source link

GridView "Select" command and SelectedIndexChanged stops the circuit #17

Closed MG1376 closed 5 months ago

MG1376 commented 5 months ago

GridView select command and selectedindexchanged event stops page circuit. after executing the event handler, the gridview and the page are disabled:

OnSelectedIndexChanged="Selected_Changed"

 <ItemTemplate TItem="GreenPaperItem">     
     <asp.LinkButton Text="Select" CommandName="Select">

     </asp.LinkButton>
     <asp.Button Text="Delete" CommandName="Delete" CssClass="btn btn-danger">

     </asp.Button>
     <asp.Button Text="Edit" CommandName="Edit" CssClass="btn btn-primary">

     </asp.Button>
 </ItemTemplate>
 int selectedValue = -1;
 protected void Selected_Changed(object sender, EventArgs e)
 {
     gvSelectedValue = Convert.ToInt32(gv.SelectedValue);
     StateHasChanged();
 }

When I hover the mouse on Edit and Delete buttons nothing appears but when I hover on Select Button a "_doPostback.." appears under the page. probably this feature is not implemented yet. the problem can be easily solved by passing context.Id to event handler and attach event handler to the button, but then it is not the asp.net way.

Jurioli commented 5 months ago

You need DataBind in SelectedIndexChanged because the original HandleSelect did not add RequiresDataBinding = true.

 protected void Selected_Changed(object sender, EventArgs e)
 {
     gvSelectedValue = Convert.ToInt32(gv.SelectedValue);
     gv.DataBind();
 }