A public method with the name '' was either not found - c#

I have a data bound grid-view with action buttons for updating and deleting items in a users shopping cart. The grid-view uses a 'SelectMethod' in the code behind to generate the data. The problem I'm having is that every time I edit some data in the grid-view, the data is successfully persisted, but then an error is thrown before the page even completes loading.
Here's the exception details:
System.InvalidOperationException:
A public method with the name '' was eithernot found or there were multiple methods with the same name on the type 'ASP.posworx_cart_aspx'.
What makes it even more confusing is that (' ') is an empty string, I checked in my code and I don't even have any attributes with an empty string value, except
for the header of an item template, which I don't think even matters really.
Here's the stack trace:
[InvalidOperationException: A public method with the name '' was either not found or there were multiple methods with the same name on the type 'ASP.posworx_cart_aspx'.]
System.Web.UI.WebControls.ModelDataSourceView.FindMethod(String methodName) +2464454
System.Web.UI.WebControls.ModelDataSourceView.RequireAsyncModelBinding(String methodName, ModelDataSourceMethod& method) +67
System.Web.UI.WebControls.ModelDataSourceView.Update(IDictionary keys, IDictionary values, IDictionary oldValues, DataSourceViewOperationCallback callback) +97
System.Web.UI.WebControls.GridView.HandleUpdate(GridViewRow row, Int32 rowIndex, Boolean causesValidation) +1210
System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +877
System.Web.UI.WebControls.GridView.OnBubbleEvent(Object source, EventArgs e) +89
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
System.Web.UI.WebControls.GridViewRow.OnBubbleEvent(Object source, EventArgs e) +90
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +121
System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +161
System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +12
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +15
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +9754214
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3562
The markup code for my grid-view:
<div class="table-responsive unbordered">
<asp:GridView ID="shoppingCartGridView" runat="server" DataKeyNames="ItemDetailId" SelectMethod="GetShoppingCartItems" AutoGenerateColumns="false" BorderColor="Transparent" BackColor="White" ForeColor="Black" CssClass="table table-hover table-condensed"
OnRowUpdating="shoppingCartGridView_RowUpdating" OnRowDeleting="shoppingCartGridView_RowDeleting" ItemType="OnlineShoppingApplication.BusinessEntities.ShoppingCart.ShoppingCartItem">
<SelectedRowStyle BackColor="#CC3333" ForeColor="White"></SelectedRowStyle>
<SortedAscendingCellStyle BackColor="#FFF"></SortedAscendingCellStyle>
<SortedAscendingHeaderStyle BackColor="#333333"></SortedAscendingHeaderStyle>
<SortedDescendingCellStyle BackColor="#FFF"></SortedDescendingCellStyle>
<SortedDescendingHeaderStyle BackColor="#333333"></SortedDescendingHeaderStyle>
<Columns>
<asp:TemplateField HeaderText="Product" HeaderStyle-Width="50%">
<ItemTemplate>
<div class="row">
<div class="col-sm-2 hidden-xs"><img class="img-responsive" src="../Images/product-image holder.gif" alt="<%#:Item.ItemDescription%>"></div>
<div class="col-sm-10">
<h4 class="bold-text nomargin">
<%#:Item.ItemDescription %>
</h4>
<p data-th="Product">
<%#:Item.ItemDescription %>
</p>
</div>
</div>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="ItemDetailId" HeaderText="Id" SortExpression="ItemDetailId" Visible="false" />
<%--<asp:TemplateField HeaderText="Name">
<ItemTemplate>
<a class="btn-link bold-text" href="<%#: GetRouteUrl("ProductByIdRoute", new {productId = Item.ItemId,productDetailId = Item.ItemDetailId})%>">
<%#:Item.ItemDescription%>
</a>
</ItemTemplate>
</asp:TemplateField>--%>
<asp:BoundField DataField="ItemPrice" ItemStyle-CssClass="btn-link item-vertical-align" HeaderText="Price" HeaderStyle-Width="10%" DataFormatString="{0:c}" />
<asp:TemplateField HeaderText="Quantity" HeaderStyle-Width="8%">
<ItemTemplate>
<asp:TextBox ID="quantityTextBox" runat="server" CssClass="form-control text-center" Text="<%#:Item.Quantity %>" TextMode="Number"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Subtotal" HeaderStyle-Width="22%" HeaderStyle-CssClass="text-center" ItemStyle-CssClass="btn-link text-center">
<ItemTemplate>
<%#:$"{(Convert.ToDouble(Item.Quantity)) * (Convert.ToDouble(Item.ItemPrice)):c}"%>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="" HeaderStyle-Width="10%">
<ItemTemplate>
<asp:LinkButton ID="updateCartItemButton" runat="server" CssClass="btn btn-info btn-sm" Text='<i class="fa fa-refresh"></i>' alt="Update item" CommandName="Update">
</asp:LinkButton>
<asp:LinkButton ID="deleteCartItemButton" runat="server" CssClass="btn btn-danger btn-sm" Text='<i class="fa fa-trash-o"></i>' alt="Delete item" CommandName="Delete">
</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<EmptyDataTemplate>
<div class="row alert alert-warning alert-dismissable fade in" style="margin-bottom:0px">
There are no items in your shopping cart
</div>
</EmptyDataTemplate>
<EmptyDataTemplate>
<div class="row alert alert-warning alert-dismissable fade in" style="margin-bottom:0px">
There are no items in your shopping cart
</div>
</EmptyDataTemplate>
</asp:GridView>
</div>
</div>
Select method for grid-view:
public IQueryable<BusinessEntities.ShoppingCart.ShoppingCartItem> GetShoppingCartItems()
{
IQueryable<BusinessEntities.ShoppingCart.ShoppingCartItem> shoppingCartItems = _cartService.GetCartItems(SiteMaster.Customer.CustomerGuid).AsQueryable();
if (shoppingCartItems != null)
{
CreateCartSummary();
}
return shoppingCartItems;
}
Finally the
shoppingCartGridView_RowUpdating Event method:
protected void shoppingCartGridView_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
try
{
int prouductDetailId = (int)shoppingCartGridView.DataKeys[e.RowIndex].Value;
TextBox quantityTextBox = (TextBox)shoppingCartGridView.Rows[e.RowIndex].FindControl("quantityTextBox");
int newQuantity = int.Parse(quantityTextBox.Text);
UpdateCartItem(prouductDetailId, newQuantity);
DisplayMessage("Your cart has been updated successfully", Bootstrap.MessageType.Success);
shoppingCartGridView.DataBind();
}
catch (Exception ex)
{
ExceptionUtility.LogException(ex, $"{this}");
}
}
And the
shoppingCartGridView_RowDeleting Event method:
protected void shoppingCartGridView_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
try
{
int productDetailId = (int)shoppingCartGridView.DataKeys[e.RowIndex].Value;
RemoveCartItem(productDetailId);
DisplayMessage("The item has been deleted from your cart", Bootstrap.MessageType.Success);
shoppingCartGridView.DataBind();
}
catch(Exception ex)
{
ExceptionUtility.LogException(ex, $"{this}");
DisplayMessage(#"An error occured while deleting the item from the cart please try again later", Bootstrap.MessageType.Danger);
}
}
Thanks in advance guys, I would highly appreciate some assistance
on this, because I really don't know what to do.

After doing some research on the ModelDataSourceView class, I found that there are properties of the class called UpdateMethod,DeleteMethod,InsertMethod (basically properties to specify the names of all the CRUD operations) .
Which then made me think that instead of having the OnRowUpdating and OnRowDeleting events fired when I update a row, why not just add an UpdateMethod attribute to the GridView(with the value of that attribute being the name of the method responsible for performing the update operation)? After all there was already a SelectMethod attribute, so it kinda made more sense to have the UpdateMethod and DeleteMethod attribute to go along with it instead of the OnRowUpdating and OnRowDeleting events being fired.
Aaaaand Walaaa!!!!! IT WORKS perfectly.
So my grid-view now looks like this(all I done was removed the OnRowUpdating attribute and added the UpdateMethod Attribute and of course, I replaced OnRowDeleting with DeleteMethod):
<asp:GridView
ID="ShoppingCartGridView"
runat="server"
DataKeyNames="ItemDetailId"
SelectMethod="GetShoppingCartItems"
UpdateMethod="ShoppingCartGridView_UpdateItem"
DeleteMethod="ShoppingCartGridView_DeleteItem"
AutoGenerateColumns="false"
BorderColor="Transparent"
BackColor="White"
ForeColor="Black"
CssClass="table table-hover table-condensed"
OnDataBound="ShoppingCartGridView_DataBound"
ItemType="OnlineShoppingApplication.BusinessEntities.ShoppingCart.ShoppingCartItem">
<SelectedRowStyle BackColor="#CC3333" ForeColor="White"></SelectedRowStyle>
<SortedAscendingCellStyle BackColor="#FFF"></SortedAscendingCellStyle>
<SortedAscendingHeaderStyle BackColor="#333333"></SortedAscendingHeaderStyle>
<SortedDescendingCellStyle BackColor="#FFF"></SortedDescendingCellStyle>
<SortedDescendingHeaderStyle BackColor="#333333"></SortedDescendingHeaderStyle>
<Columns>
<asp:TemplateField HeaderText="Product" HeaderStyle-Width="50%">
<ItemTemplate>
<div class="row">
<div class="col-sm-2 hidden-sm hidden-xs">
<img class="img-responsive" src="../Images/product-image holder.gif" alt="<%#:Item.ItemDescription%>"></div>
<div class="col-sm-10">
<h4 class="bold-text nomargin"><%#:Item.ItemDescription %></h4>
<p data-th="Product">
<a
href="<%#:GetRouteUrl("ProductByIdRoute", new {productId = Item.ItemId,productDetailId = Item.ItemDetailId})%>"
class="btn-link"><%#:$"{Item.SizeCurve} {Item.Colour} {Item.ItemDescription}"%>
</a>
</p>
</div>
</div>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="ItemDetailId" HeaderText="Id" SortExpression="ItemDetailId" Visible="false" />
<asp:BoundField DataField="ItemPrice" ItemStyle-CssClass="currency item-vertical-align" HeaderText="Price" HeaderStyle-Width="10%" DataFormatString="{0:F2}"/>
<asp:TemplateField HeaderText="Quantity" HeaderStyle-Width="8%">
<ItemTemplate>
<asp:TextBox ID="quantityTextBox" runat="server" CssClass="form-control text-center" Text="<%#:Convert.ToInt32(Item.Quantity) %>" TextMode="Number"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Subtotal" HeaderStyle-Width="22%" HeaderStyle-CssClass="text-center" ItemStyle-CssClass="text-center">
<ItemTemplate>
<%#:$"{Convert.ToInt32((Convert.ToDouble(Item.Quantity)) * (Convert.ToDouble(Item.ItemPrice)))}"%>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText=" " HeaderStyle-Width="10%" ItemStyle-CssClass="action">
<ItemTemplate>
<asp:LinkButton
ID="updateCartItemButton"
runat="server"
CssClass="btn btn-info btn-sm"
Text='<i class="fa fa-refresh"></i>'
alt="Update item"
CommandName="Update">
</asp:LinkButton>
<asp:LinkButton
ID="deleteCartItemButton"
runat="server"
CssClass="btn btn-danger btn-sm"
Text='<i class="fa fa-trash-o"></i>'
alt="Delete item"
CommandName="Delete">
</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<EmptyDataTemplate>
<div class="row alert alert-warning alert-dismissable fade in" style="margin-bottom: 0px">
There are no items in your shopping cart
</div>
</EmptyDataTemplate>
<EmptyDataTemplate>
<div class="row alert alert-warning alert-dismissable fade in" style="margin-bottom: 0px">
There are no items in your shopping cart
</div>
</EmptyDataTemplate>
</asp:GridView>
Here's my new, but not so different UpdateMethod referenced in the grid-view:
public void shoppingCartGridView_UpdateItem(int ItemDetailId)
{
try
{
int rowIndex = GetRowIndexByItemDetailId(ItemDetailId);
TextBox quantityTextBox = (TextBox)ShoppingCartGridView.Rows[rowIndex].FindControl("quantityTextBox");
int newQuantity = int.Parse(quantityTextBox.Text);
UpdateCartItem(ItemDetailId, newQuantity);
DisplayMessage("Your cart has been updated successfully", Bootstrap.MessageType.Success);
ShoppingCartGridView.DataBind();
}
catch (Exception ex)
{
ExceptionUtility.LogException(ex, $"{this}");
DisplayMessage(#"An error occured while updating your cart item,
please try again in a moment", Bootstrap.MessageType.Danger);
}
}

Related

ImageButton In UpdatePanel Doesn't Firing [Asp.net]

i'm have a problem with button clicked in asp.net update panel. Here My Code :
My Aspx Code :
<asp:UpdatePanel runat="server" ID="UpdatePanel1" UpdateMode="Conditional">
<ContentTemplate>
<div class="modal fade modal-lg" id="mdlVendor" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="mdlVendorLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="mdlVendorLabel">Vendor</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<div class="row">
<div class="col-md-3">
<asp:Label runat="server" ></asp:Label>
<asp:TextBox runat="server" ID="txtVendorSearch" CssClass="form-control me-2" OnClientClick="javascript:return false;" data-target="#mdlVendor" OnTextChanged="txtVendorSearch_TextChanged" AutoPostBack="true"></asp:TextBox>
<br />
</div>
<div class="col-md-3">
</div>
</div>
<asp:GridView ID="gvVendor" runat="server" CellPadding="4" ForeColor="#333333" GridLines="None" AutoGenerateColumns="false" Width="100%" OnRowCommand="gvVendor_RowCommand">
<AlternatingRowStyle BackColor="White" />
<EditRowStyle BackColor="#2461BF" />
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#EFF3FB" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#F5F7FB" />
<SortedAscendingHeaderStyle BackColor="#6D95E1" />
<SortedDescendingCellStyle BackColor="#E9EBEF" />
<SortedDescendingHeaderStyle BackColor="#4870BE" />
<EmptyDataTemplate>
<asp:Label runat="server" ID="lblEmptyData" Text="No Data Found"></asp:Label>
</EmptyDataTemplate>
<Columns>
<asp:TemplateField HeaderText="Vendor Id">
<ItemTemplate>
<asp:Label runat="server" ID="VendorID" Text='<%# Eval("VendorID") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Vendor Name">
<ItemTemplate>
<asp:Label runat="server" ID="VendorName" Text='<%# Eval("VendorName") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:ImageButton ImageUrl="~/img/add.png" runat="server" Width="20px" Height="20px" CommandName="SelectDataVendor" ToolTip="Select Data Vendor"/>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
My Aspx.cs Code :
protected void gvVendor_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName.Equals("SelectDataVendor"))
{
GridViewRow row = (GridViewRow)(((ImageButton)e.CommandSource).NamingContainer);
int index = row.RowIndex;
GridViewRow clickedRow = gvVendor.Rows[index];
Label VendorName = (Label)clickedRow.Cells[2].FindControl("VendorName");
txtVendor.Text = VendorName.Text;
}
}
protected void txtVendorSearch_TextChanged(object sender, EventArgs e)
{
ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModal();", true);
DataTable dt = new DataTable();
string StrSeacrh = txtVendorSearch.Text;
dt = trxExpenditureCls.GetVendor(StrSeacrh);
if (dt.Rows.Count > 0)
{
gvVendor.DataSource = dt;
gvVendor.DataBind();
}
else
{
dt.Rows.Add(dt.NewRow());
gvVendor.DataSource = dt;
gvVendor.DataBind();
gvVendor.Rows[0].Cells.Clear();
gvVendor.Rows[0].Cells.Add(new TableCell());
gvVendor.Rows[0].Cells[0].ColumnSpan = dt.Columns.Count;
gvVendor.Rows[0].Cells[0].Text = "No Data Found";
gvVendor.Rows[0].Cells[0].HorizontalAlign = HorizontalAlign.Center;
}
}
When i'm click imageButton :
<asp:ImageButton ImageUrl="~/img/add.png" runat="server" Width="20px" Height="20px" CommandName="SelectDataVendor" ToolTip="Select Data Vendor"/>
system doesn't debug into gvVendor_RowCommand. When i make breakpoint in Page_Load, debugger goes into method gvVendor_RowCommand too. But i get a problem, txtVendor doesn't filled after debugger finish.
I'm already try :
<asp:UpdatePanel runat="server" ID="updPnl2" UpdateMode="Conditional">
<ContentTemplate>
<asp:ImageButton ImageUrl="~/img/add.png" runat="server" Width="20px" Height="20px" CommandName="SelectDataVendor" ToolTip="Select Data Vendor" ID="btnAdd"/>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger controlid="btnAdd" eventname="Click" />
</Triggers>
</asp:UpdatePanel>
And both
<asp:AsyncPostBackTrigger controlid="btnAdd" eventname="Click" />
Or
<asp:PostBackTrigger controlid="btnAdd" />
None of All fix my problem, even i have tried :
<asp:UpdatePanel runat="server" ID="updPnl2" UpdateMode="Conditional">
<ContentTemplate>
<asp:Button runat="server" ID="btnAddNewData" OnClick="bntAddNewData_Click" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger controlid="btnAddNewData" eventname="Click" />
</Triggers>
</asp:UpdatePanel>
Still doesn't fix my problem, is anyone can help me? i'm stuck here. Thanks you before
Hum, I don't think the introduction of a update panel should matter.
On the other hand? I long ago dumped the use of the row command.
Most don't realize that you can drop in a standard asp.net button, or image button.
Just wire up a plane jane click event for the code behind. The beauty of this approach is you don't have to clutter up bunch of events into the row command.
(VERY little reason to bother or use that).
So, say we drop in a button into the GV.
Now, we can't double click on the button in the designer to auto wire up a event, but you can do this in the markup. Just type in onclick= -- and intel-sense will pop this up:
So, choose create new event.
And now you have this code for the image button click event:
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
ImageButton btn = (ImageButton)sender;
GridViewRow gRow = (GridViewRow)btn.NamingContainer;
// get pkID
int PKID = (int)GridView1.DataKeys[gRow.RowIndex]["ID"];
Debug.Print("PK ID = " + PKID);
Debug.Print("Row index click = " + gRow.RowIndex);
Label VendorName = (Label)gRow.FindControl("VendorName");
txtVendor.Text = VendorName.Text;
}
So you don't have to use row command. But, you can drop in a plain jane button, or image button - just wire up a plain old regular event. You can pick up the current row as per above, and you off to the races.

problem handling Gridview_SelectIndexChanging event with an UpdatePanel ASP.NET

i will try to explain what i have, what i'm trying to do and what is my problem
what i have:
i have a modal with and update panel (i need it because the postback closes my modal) that has two text box, a button and a gridview.
in the textbox i write the name and the surname of a person and with the button i retrieve the data and put it in a gridview.
the gridview has a control to select the row that i want, with that row, i use the data from first three cells to change some hidenField values to use in another function.
in the bottom of the modal i have the add button that only changes a textbox to show that i have the correct data. that button is not enabled by default and the event must enable it
what i want:
i want to select the row that i need, enable the add button and fetch the data in my textbox.
where is my problem:
when i select my row, selectedindexchanging fires but nevers enables the add button so cant fetch my textbox for using it
code:
front code:
<div class="modal fade" id="modalSocio" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="staticBackdropLabel" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="staticBackdropLabelSocio">
<asp:Label ID="Label4" runat="server" CssClass="text-primary"></asp:Label>
</h5>
</div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" >
<ContentTemplate>
<div class="modal-body">
<div class="row g-3">
<div class="row">
<div class="col-3">
<asp:TextBox ID="txtBusquedaNombre" runat="server" CssClass="form-control" placeholder="Nombre"></asp:TextBox>
</div>
<div class="col-3">
<asp:TextBox ID="txtBusquedaApellido" runat="server" CssClass="form-control" placeholder="Apellido"></asp:TextBox>
</div>
<div class="col-3">
<asp:LinkButton ID="btnBuscarSocio" runat="server" CssClass="btn btn-outline-success" Text="Buscar" CausesValidation="false" ToolTip="Buscar" OnClick="btnBuscarSocio_Click" ><span class="fas fa-search"></span></asp:LinkButton>
</div>
</div>
<div class="table-responsive mt-3">
<asp:GridView ID="gvSocios" runat="server" CssClass="table table-bordered" AutoGenerateColumns="False" CellPadding="4" ForeColor="#333333" GridLines="None" OnSelectedIndexChanging="gvSocios_SelectedIndexChanging" >
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:BoundField DataField="Legajo" HeaderText="Nro. Socio" ></asp:BoundField>
<asp:BoundField DataField="nombreSocio" HeaderText="Nombre" />
<asp:BoundField DataField="Apellido" HeaderText="Apellido" />
<asp:CommandField ButtonType="Link" HeaderText="Seleccionar" ShowSelectButton="True" SelectText="<i class='fa fa-check-circle'></i>">
<ControlStyle CssClass="btn btn-outline-secondary" />
</asp:CommandField>
</Columns>
<EditRowStyle BackColor="#2461BF" />
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#EFF3FB" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#F5F7FB" />
<SortedAscendingHeaderStyle BackColor="#6D95E1" />
<SortedDescendingCellStyle BackColor="#E9EBEF" />
<SortedDescendingHeaderStyle BackColor="#4870BE" />
<EmptyDataTemplate>
<div class="alert alert-primary" role="alert">
No se encontraron registros!
</div>
</EmptyDataTemplate>
</asp:GridView>
</div>
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
<div class="modal-footer">
<asp:Button ID="BtnCancelarSocio" runat="server" Text="Cancelar" CssClass="btn btn-secondary" OnClick="btnCancelar_Click" CausesValidation="False" />
<asp:Button ID="BtnAgregarSocio" ClientIDMode="Static" runat="server" CausesValidation="false" Text="Seleccionar" CssClass="btn btn-success" OnClick="BtnAgregarSocio_Click" />
</div>
</div>
</div>
</div>
codeBehind:
protected void BtnAgregarSocio_Click(object sender, EventArgs e)
{
TxtSocio.Text = hfidNombreSocio.Value;
}
protected void gvSocios_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
{
var row = gvFormasPago.Rows[e.NewSelectedIndex];
BtnAgregarSocio.Enabled = true;
hfSocio.Value = row.Cells[0].Text;
hfidNombreSocio.Value = row.Cells[0].Text + " - " + row.Cells[1].Text + " " + row.Cells[2].Text;
}
i tried to not use the enabled attribute for test but when the click event fires the hfidNombreSocio value in that moment is empty and the modal never closes.
maybe i'm not using the update panel right.
the text box code:
<div class="row">
<div class="col-md-4">
<asp:Label ID="lblSocio" runat="server" Visible="false" Text="Socio Cuenta Corriente" CssClass="form-label"></asp:Label>
<asp:TextBox ID="TxtSocio" runat="server" text="0" CssClass="form-control" ></asp:TextBox>
<asp:LinkButton ID="btnBuscar" runat="server" Visible="false" CssClass="btn btn-outline-success" Text="Buscar" CausesValidation="false" ToolTip="Buscar" OnClick="btnBuscar_Click" ><span class="fas fa-search"></span></asp:LinkButton> <%-- this button open the modal --%>
</div>
Ok, folks, this is one of those I wish someone corrected me!!
I am MOST HAPPY to have big buckets of egg on my face.
I have for some time preached that when you pop a dialog, you can't have post backs in that dialog. I stand MUCH corrected!!!!
So, lets build a grid, it allows a search, and then we can click on (select the row).
We have this:
<div id="hoteldialog1" style="display:normal">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
Enter City Name: <asp:TextBox ID="txtSearchCity" runat="server"></asp:TextBox>
<asp:Button ID="cmdSearchCity" runat="server" Text="Search"
style="margin-left:25px" CssClass="btn" OnClick="cmdSearchCity_Click"/>
<br />
<asp:GridView ID="GridHotels" runat="server" AutoGenerateColumns="False"
DataKeyNames="ID" OnSelectedIndexChanged="GridHotels_SelectedIndexChanged"
CssClass="table">
<Columns>
<asp:BoundField DataField="HotelName" HeaderText="HotelName" />
<asp:BoundField DataField="City" HeaderText="City" />
<asp:BoundField DataField="Province" HeaderText="Province" />
<asp:BoundField DataField="Description" HeaderText="Description" />
<asp:TemplateField HeaderText="Select">
<ItemTemplate>
<asp:Button ID="cmdHSel" runat="server" Text="Select"
CommandName="Select"/>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
</div>
So, when we run, we get/see this:
Now, in above I DID use CommmandName = "select" because I wanted the select row to work. (and I beyond hate all those extra templates). So I used this code to highlight the row.
protected void GridHotels_SelectedIndexChanged(object sender, EventArgs e)
{
// user selected this row - highlight it
int RowIX = GridHotels.SelectedIndex;
GridViewRow gRow = (GridViewRow)GridHotels.Rows[RowIX];
if ((ViewState["MySel"] != null) && ((int)ViewState["MySel"] != RowIX))
{
GridViewRow gLast = GridHotels.Rows[(int)ViewState["MySel"]];
gLast.CssClass = "";
}
gRow.CssClass = "alert-info";
ViewState["MySel"] = RowIX;
}
Ok, so far so simple. And the search button in above is this:
protected void cmdSearchCity_Click(object sender, EventArgs e)
{
using (SqlConnection conn = new SqlConnection(Properties.Settings.Default.TEST4))
{
using (SqlCommand cmdSQL = new SqlCommand("SELECT * FROM tblHotels ", conn))
{
if (txtSearchCity.Text != "")
{
// filter grid by city
cmdSQL.CommandText += " WHERE City = #City";
cmdSQL.Parameters.Add("#City", SqlDbType.NVarChar).Value = txtSearchCity.Text;
}
conn.Open();
cmdSQL.CommandText += " ORDER BY HotelName";
GridHotels.DataSource = cmdSQL.ExecuteReader();
GridHotels.DataBind();
}
}
}
Again, really simple.
Ok, now the money shot. Now the Rosetta stone. Now the beef, now the magic, now the amazing!!!
The above as noted was placed in a "div", and has a update panel.
So, now lets drop in another grid!!!
We going to display some people, and pop the above hotel selector grid!!
So, we now have this:
<asp:GridView ID="GPeople" runat="server" AutoGenerateColumns="False"
DataKeyNames="ID" >
<Columns>
<asp:BoundField DataField="Firstname" HeaderText="Firstname" />
<asp:BoundField DataField="LastName" HeaderText="LastName" />
<asp:BoundField DataField="City" HeaderText="City" />
<asp:BoundField DataField="Province" HeaderText="Province" />
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="cmdGetHotel" runat="server" Text="Hotels"
OnClick="cmdGetHotel_Click"
OnClientClick="return mypop(this);"
/>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
And code:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
LoadPeople();
}
void LoadPeople()
{
GPeople.DataSource = MyRst("SELECT * from People Order by FirstName");
GPeople.DataBind();
}
So we now have a grid of people. We now want to on a row click, pop up the hotel list.
So, I suggest jQuery.UI, as is much better (and cleaner then bootstrap dialog).
So we have this row click in above:
<asp:Button ID="cmdGetHotel" runat="server" Text="Hotels"
OnClick="cmdGetHotel_Click"
OnClientClick="return mypop(this);"
/>
So in above, we have both a server side button, and then a client side js function that pops up the dialog (and ONLY returns true if we hit ok.
So, now all we need is the js code to pop up the dialog. That code is this:
<script>
selok = false;
function mypop(btn) {
if (selok)
return true;
var mydiv = $("#hoteldialog1")
mydiv.dialog({
modal: true, appendTo: "form",
title: "Test dialog", closeText: "",
width: "40%",
position: { my: 'left top', at: 'right bottom', of: btn },
buttons: {
Ok: (function () {
selok = true;
btn.click()
}),
Cancel: (function () {
mydiv.dialog("close")
})
}
});
return false;
}
</script>
(set hotel grid display:none - jquery.ui will manage this).
So, now we get this:
So we are free to search, have post-backs, and of course select the row.
If the user hits ok, then the first grid button code runs. I did NOT use the selected index change event for that first grid (I could have), but I used this code:
protected void cmdGetHotel_Click(object sender, EventArgs e)
{
Debug.Print("hotel grid click");
Button btn = (Button)sender;
GridViewRow gRow = (GridViewRow)btn.Parent.Parent;
Debug.Print("Grid row = " + gRow.RowIndex);
Debug.Print("PK = " + GPeople.DataKeys[gRow.RowIndex]["ID"].ToString());
Also note, that while the pop grid is hidden? We can STILL get any data from that row, since the selected index of that grid does persist!!
eg:
GridViewRow gRow = (GridViewRow)GHotels.Rows[GHotels.SelectedIndex];
Debug.Print("Grid row = " + gRow.RowIndex);
Debug.Print("PK = " + GPeople.DataKeys[gRow.RowIndex]["ID"].ToString());
// cells collection, or find control to grab any other value
So, I think you should dump the bootstrap dialog.
Put your 2nd nice grid + searching, post backs - what ever you want into a div with a name, and use jQuery.UI to pop the grid. This will allow searching, post backs and then when the user selects the row and hits ok, then you are now free to close this dialog, and you have "index" of that pop set for you.

DropDownList inside GridView inside Repeater Control not working properly

I'm using Repeater control to generate tables on my dashboard. In the repeater, is a gridview to display item details. In the first column og the gridview is a dropdownlist to select an item and on selected index of that item, I'm fetching item details and the billing process continues for each table. Now the problem is that I'm only able to get the item details in the first repeater. Nothing happens when I select an item in another table or repeater. kindly help me with this issue.
Here is my ASPX markup:
<div class="row">
<asp:Repeater ID="rptrTables" runat="server" OnItemDataBound="rptrTables_ItemDataBound">
<ItemTemplate>
<div class="col-md-6">
<div class="card card-info">
<div class="card-header with-border">
<h3 class="card-title"><asp:Label ID="lblTableNumber" runat="server" Text='<%# Eval("TableName") %>'></asp:Label></h3>
<div class="card-tools">
<button type="button" class="btn btn-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
</div>
</div>
<div class="card-body">
<div class="row">
<div class="col-md-12">
<div class="form-group">
<asp:GridView ID="grdOrder" runat="server" AutoGenerateColumns="false" AllowPaging="true" CssClass="table table-bordered table-hover table-responsive" GridLines="None" PageSize="10" OnRowDataBound="gvRowDataBound">
<Columns>
<asp:CommandField ShowDeleteButton="true" ControlStyle-CssClass="btn btn-danger fa fa-trash" DeleteText="" HeaderText="Remove" />
<asp:BoundField DataField="RowNumber" HeaderText="Sl. No." />
<asp:TemplateField HeaderText="Item Name">
<ItemTemplate>
<asp:DropDownList ID="drpItemname" runat="server" CssClass="form-control select2" OnSelectedIndexChanged="GetItemDetails" AutoPostBack="true"></asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Price">
<ItemTemplate>
<asp:Label ID="lblUnitPrice" runat="server" Text='<%# Eval("UnitPrice")%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Qty">
<ItemTemplate>
<asp:Label ID="lblQuantity" runat="server" Text='<%# Eval("Quantity")%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Line Total">
<ItemTemplate>
<asp:Label ID="lblLineTotal" runat="server" Text="0"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Add Item" ConvertEmptyStringToNull="False">
<ItemTemplate>
<asp:Button ID="ButtonAdd" runat="server" CssClass="btn btn-primary" Text="Add" OnClick="AddItem" CausesValidation="False" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
</div>
</div>
</div>
<div class="card-footer">
<div class="pull-right">
<asp:Button ID="btnSubmit" runat="server" CausesValidation="false" TabIndex="2" CssClass="btn btn-primary" Text="Print KOT" />
<asp:Button ID="Button1" runat="server" CausesValidation="false" TabIndex="2" CssClass="btn btn-primary" Text="Print Final Bill" />
<asp:Button ID="Button2" runat="server" CausesValidation="false" TabIndex="2" CssClass="btn btn-primary" Text="Complete Order" />
</div>
</div>
</div>
</div>
</ItemTemplate>
</asp:Repeater>
</div>
And my c# code to fetch item details:
protected void GetItemDetails(object sender, EventArgs e)
{
foreach(RepeaterItem rptrItems in rptrTables.Items)
{
GridView gvItems = (GridView)rptrTables.Items[0].FindControl("grdOrder");
foreach (GridViewRow row in gvItems.Rows)
{
DropDownList ddl = sender as DropDownList;
Control ctrl = row.FindControl("drpItemName") as DropDownList;
if (ctrl != null)
{
DropDownList ddl1 = (DropDownList)ctrl;
if (ddl.ClientID == ddl1.ClientID)
{
Label UnitPrice = row.FindControl("lblUnitPrice") as Label;
Label QTTY = row.FindControl("lblQuantity") as Label;
Label UPrice = row.FindControl("lblUnitPrice") as Label;
Label LINETOTAL = row.FindControl("lblLineTotal") as Label;
SqlConnection conn = new SqlConnection(constring);
conn.Open();
if (ctrl != null)
{
if ((ddl1.ID == ddl.ID) && (ddl1.SelectedIndex == ddl.SelectedIndex))
{
string str = "select * from ItemMaster where ItemName='" + ddl1.SelectedItem.ToString() + "'";
SqlCommand com = new SqlCommand(str, conn);
SqlDataReader reader = com.ExecuteReader();
while (reader.Read())
{
UnitPrice.Text = reader["UnitPrice"].ToString();
QTTY.Text = reader["Quantity"].ToString(); ;
decimal totamt = Convert.ToDecimal(QTTY.Text) * Convert.ToDecimal(UnitPrice.Text);
}
reader.Close();
conn.Close();
}
else
{
ScriptManager.RegisterStartupScript(this, this.GetType(), "swal", "swal('Item already selected, you can increase the quantity instead!', 'warning');", true);
}
}
}
}
}
}
}
There is a problem in your code. you are always selecting the first item from the repeater control,
GridView gvItems = (GridView)rptrTables.Items[0].FindControl("grdOrder");
Change your code to get the item from foreach loop, so your code will be
GridView gvItems = (GridView)rptrItems.FindControl("grdOrder");
try to use rptrItems instead of the first item of the repeater control each time.
Hope this will help.

Cant access textbox inside gridview inside modalpopup

I have the below a gridview inside a modal popup, I use update a textbox inside an edititemtemplate,then use linkbutton to trigger a postback event so I can save the value inside the textbox for that gridview row,but at code bhind I cant access the textbox when I use findcontrol.
Please assit
<div id="userForm" class="form-horizontal" style="display:none;width:100%;border:solid 0px;" >
<input ID="btnshowRun" type="button" Value="Show Leave" class="btn btn-warning " style="float:lefts;" OnClick ="showhide();"/>
<asp:UpdatePanel ID="UpdatePanel5" runat="server" style="display:none;">
<ContentTemplate>
<asp:GridView ID="GridView2" runat="server" AllowSorting="False"
AutoGenerateColumns="False" DataKeyNames="EntryID"
EmptyDataText="There are no data records to display."
ShowFooter="False" HorizontalAlign="Center" OnRowCommand="gvl_RowCommand"
ShowHeaderWhenEmpty="True" CssClass="table table-striped table-bordered table-hover table-responsive table-condenseds " Width="100%" GridLines="None">
<Columns>
<asp:TemplateField HeaderText="Total" SortExpression="Total">
<EditItemTemplate>
<asp:TextBox ID="Tot" runat="server" Text='<%# Bind("Total") %>' class="form-control"></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label4" runat="server" Text='<%# Bind("Total") %>'></asp:Label>
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" />
</asp:TemplateField>
<asp:TemplateField ShowHeader="False">
<EditItemTemplate>
<asp:LinkButton ID="CommandButton" runat="server" CommandArgument='<%# Eval("EntryID") %>' UseSubmitBehaviour=true CausesValidation="False"
CommandName="Update" OnCommand="Updates_Command" Text="Update" class="btn btn-primary btn-sm contrl" Style="margin-right: 10px;"
/>
<asp:LinkButton ID="Button2" runat="server" CausesValidation="False" CommandName="Cancel" class="btn btn-warning btn-sm contrl" Style="margin-right: 10px;"
Text="Cancel" />
</EditItemTemplate>
<ItemTemplate>
<asp:LinkButton ID="Button1" runat="server" CommandArgument='<%# Eval("EntryID") %>' class="form-control btn btn-default btn-blocks contrl btn-sms"
CommandName="Edit" OnCommand="Button1_Command" Text="Edit" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<HeaderStyle HorizontalAlign="Center" Font-Bold="True" ForeColor="Black"></HeaderStyle>
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
</div>
This is how am accessing the control in C#
protected void Updates_Command(object sender, CommandEventArgs e)
{
Control p = ((Control)sender).Parent;
int tot = int.Parse(((TextBox)p.FindControl("Tot")).Text);
int rowid = int.Parse(Session["RowID"].ToString());
int suc = Database.ExecuteNonQuery("UPDATE LeaveAssignmentEntry SET Total='" + tot + "' WHERE Id = " + rowid + "");
if (suc==1)
{
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('Successful')", true);
}
}
you can use this code to find control inside template :
int index = Convert.ToInt32(e.CommandArgument);
GridViewRow selectedRow = GridView2.Rows[index];
TextBox tot = (TextBox)selectedRow.FindControl("Tot");
Use below line to get text from TextBox with FindControl method:
string tot = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("Tot")).Text;

Invalid postback or callback argument when redirect on a SelectedIndexChanged from a gridview

Hi Im trying to redirect to another page on the gridView event: selectedIndexChanged. I dont want to set EnableEventValidation="false".
here is my code
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
llenarGridViewClientes();
}
}
protected void GridViewUsuarios_SelectedIndexChanged(object sender, EventArgs e)
{
Session["UsuarioHistoria"] = GridViewUsuarios.SelectedValue;
Response.Redirect("Historia.aspx");
}
And page:
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<div class="form-group">
<div class="input-group">
<asp:TextBox ID="txtBuscador" runat="server" CssClass="form-control" ></asp:TextBox>
<span class="input-group-btn">
<asp:Button ID="btnBuscar" runat="server" CssClass="btn btn-primary " Text="Buscar" OnClick="btnBuscar_Click"/>
</span>
</div>
</div>
<div id="divGrid" style="overflow: auto; height: 430px" >
<asp:GridView ID="GridViewUsuarios" runat="server" AutoGenerateColumns="False" AllowSorting="True" CellPadding="1" CssClass="table table-striped table-hover" GridLines="None" ShowHeaderWhenEmpty="True" ForeColor="#333333"
DataKeyNames="id" AllowPaging="False" Font-Names="Arial" Font-Size="Small" OnSelectedIndexChanged="GridViewUsuarios_SelectedIndexChanged">
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:CommandField ShowSelectButton="True" SelectText="Seleccionar" />
<asp:BoundField DataField="id" HeaderText="id" SortExpression="id" InsertVisible="False" ReadOnly="True" Visible="false" />
<asp:BoundField DataField="nombre" HeaderText="Nombre" SortExpression="nombre" />
<asp:BoundField DataField="apellido" HeaderText="Apellido" SortExpression="apellido" />
<asp:BoundField DataField="telefono" HeaderText="Telefono" SortExpression="telefono" />
<asp:BoundField DataField="celular" HeaderText="Celular" SortExpression="celular" />
<asp:BoundField DataField="dni" HeaderText="DNI" SortExpression="dni" />
</Columns>
<EditRowStyle BackColor="#2461BF" />
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#EFF3FB" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#F5F7FB" />
<SortedAscendingHeaderStyle BackColor="#6D95E1" />
<SortedDescendingCellStyle BackColor="#E9EBEF" />
<SortedDescendingHeaderStyle BackColor="#4870BE" />
</asp:GridView>
</div>
</asp:Content>
And here is the master page.
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:Timer ID="tmrRelojInterno" runat="server" OnTick="tmrRelojInterno_Tick1" Interval="1000"></asp:Timer>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="tmrRelojInterno" EventName="Tick" />
</Triggers>
<ContentTemplate>
<asp:Image ID="Image1" runat="server" ImageUrl="~/logo.png" ImageAlign="Middle" Height="159px" with="934px" />
<div style="display: inline-block">
<p>
<asp:Label ID="lbldia" runat="server" Font-Names=" arial" Font-Size="Medium" ForeColor="black" Font-Bold="True"></asp:Label>
</p>
<p>
<asp:Label ID="lblReloj" runat="server" Font-Names="arial" Font-Size="XX-Large"></asp:Label>
</p>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</div>
<div class="navbar navbar-inverse">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-inverse-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="navbar-collapse collapse navbar-inverse-collapse">
<ul class="nav navbar-nav">
<li>Turnos</li>
<li>Historia Clinica</li>
<li class="dropdown">
Datos <b class="caret"></b>
<ul class="dropdown-menu">
<li>Usuarios</li>
<li>Profesiones</li>
<li>Clientes</li>
<li>Servicios</li>
</ul>
</li>
<li class="dropdown">
Consultar <b class="caret"></b>
<ul class="dropdown-menu">
<li>Turnos Eliminados</li>
</ul>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<p class="navbar-text">
<asp:LoginView ID="LoginView1" runat="server" EnableViewState="false">
<LoggedInTemplate>
<asp:LoginName ID="HeadLoginName" runat="server" Font-Bold="False" Font-Size="12" ForeColor="White" />
[
<asp:LoginStatus ID="HeadLoginStatus" runat="server" LogoutAction="Redirect" LogoutText="Cerrar sesiĆ³n" LogoutPageUrl="~/" Font-Bold="False" Font-Size="12" ForeColor="White" />
]
</LoggedInTemplate>
</asp:LoginView>
</p>
</ul>
</div>
</div>
<div class="container-fluid">
<div class="row">
<div class="col-lg-2 ">
<asp:ContentPlaceHolder ID="content3" runat="server">
</asp:ContentPlaceHolder>
</div>
<div class="col-lg-6 ">
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</div>
<div class="col-lg-4">
<asp:ContentPlaceHolder ID="ContentPlaceHolder2" runat="server"></asp:ContentPlaceHolder>
</div>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
</form>
</body>
this is the stack trace
[ArgumentException: Invalid postback or callback argument. Event
validation is enabled using in
configuration or <%# Page EnableEventValidation="true" %> in a page.
For security purposes, this feature verifies that arguments to
postback or callback events originate from the server control that
originally rendered them. If the data is valid and expected, use the
ClientScriptManager.RegisterForEventValidation method in order to
register the postback or callback data for validation.]
System.Web.UI.ClientScriptManager.ValidateEvent(String uniqueId,
String argument) +144
System.Web.UI.WebControls.TextBox.LoadPostData(String postDataKey,
NameValueCollection postCollection) +126
System.Web.UI.WebControls.TextBox.System.Web.UI.IPostBackDataHandler.LoadPostData(String
postDataKey, NameValueCollection postCollection) +13
System.Web.UI.Page.ProcessPostData(NameValueCollection postData,
Boolean fBeforeLoad) +303
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
+1960
Try adding [YourFormName].Action = Request.RawURL; to the page_load event of your master page, that resolved this issue for me.

Categories

Resources