CodeVerge.Net Beta


   Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums




Can Reply:  No Members Can Edit: No Online: Yes
Zone: > Asp.Net Forum > visual_studio.visual_studio_2005 Tags:
Item Type: Date Entered: 12/3/2007 3:32:58 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
NR
XPoints: N/A Replies: 2 Views: 95 Favorited: 0 Favorite
3 Items, 1 Pages 1 |< << Go >> >|
"billylam" <>
NewsGroup User
Major Error doing a nested datagrid (VB)12/3/2007 3:32:58 PM

0

Hi guys,

 I was hoping for any kind souls to help me solve this problem.

I was trying to do a nested datagrid which i found in : http://www.codeproject.com/aspnet/EditNestedDataGrid.asp

Bascially, my idea was to use the nested datagrid to present a list of Inventory. 

For certian Inventory, there are spare parts for the inventory (example : a Computer(Inventory) has many spare parts like HDD(spare part), RAM(spare part) and etc) 

I would like to present the spare parts in the nested datagrid under each inventory

 

 Here's the problem :

When i run the page and click on the linkbutton i got this error message :

Invalid postback or callback argument.  Event validation is enabled using <pages enableEventValidation="true"/> 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.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentException: Invalid postback or callback argument.  Event validation is enabled using <pages enableEventValidation="true"/> 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.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[ArgumentException: Invalid postback or callback argument.  Event validation is enabled using <pages enableEventValidation="true"/> 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) +2127900
   System.Web.UI.Control.ValidateEvent(String uniqueID, String eventArgument) +106
   System.Web.UI.WebControls.ImageButton.RaisePostBackEvent(String eventArgument) +32
   System.Web.UI.WebControls.ImageButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102
 

I had done some research on the net and people said that it is a security issue. I tried adding

EnableEventValidation=false

But although the error message does not appear again, when i click on the imagebutton, it didnt execute the msgbox command. However, the linkButton did work. Hopefully you guys who are more experienced can help me. I thank your in advance. Below are the aspx file code and some of the vb file code. If your can provide the solutions in vb.net, that will be great.

The following is my aspx file :

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

<%@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false"

CodeFile="adm_Inventory.aspx.vb" Inherits="adm_Inventory" Title="adm_Inventory" %>

<%-- Register web part for search--%>

<%@ Register Src="~/Page_Inventory/SearchInventory.ascx" TagPrefix="Search" TagName="InventorySearch" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">

<asp:Label ID="lblHeader" runat="server" Text="Inventory" CssClass="Header"></asp:Label>

<hr/>

<asp:WebPartManager ID="WPMInventory" runat="server">

</asp:WebPartManager>

<asp:WebPartZone ID="SearchInventory" Width="400" runat="server" BorderColor="#CCCCCC"

Font-Names="Verdana" Padding="6" HeaderText="Search">

<PartChromeStyle BackColor="#F7F6F3" BorderColor="#E2DED6" Font-Names="Verdana" ForeColor="White" />

<CloseVerb Visible="False" />

<MinimizeVerb Enabled="true" Visible="true" />

<MenuLabelHoverStyle ForeColor="#E2DED6" />

<EmptyZoneTextStyle Font-Size="0.8em" />

<MenuLabelStyle ForeColor="White" />

<MenuVerbHoverStyle BackColor="#F7F6F3" BorderColor="#CCCCCC" BorderStyle="Solid"

BorderWidth="1px" ForeColor="#333333" />

<HeaderStyle Font-Size="0.7em" ForeColor="#CCCCCC" HorizontalAlign="Center" />

<MenuVerbStyle BorderColor="#5D7B9D" BorderStyle="Solid" BorderWidth="1px" ForeColor="White" />

<PartStyle Font-Size="0.8em" ForeColor="#333333" />

<TitleBarVerbStyle Font-Size="0.6em" Font-Underline="False" ForeColor="White" />

<MenuPopupStyle BackColor="#5D7B9D" BorderColor="#CCCCCC" BorderWidth="1px" Font-Names="Verdana"

Font-Size="0.6em" />

<PartTitleStyle BackColor="#5D7B9D" Font-Bold="True" Font-Size="0.8em" ForeColor="White" />

<ZoneTemplate>

<Search:InventorySearch ID="InventorySearchAscx" title="Search" runat="server" />

</ZoneTemplate>

</asp:WebPartZone>

<table width="100%">

<tr>

<td colspan="2">

<asp:DataGrid ID="grdData" runat="server" AllowPaging="True" AllowSorting="True"

AutoGenerateColumns="False" CssClass="ui_Datagrid_Style1" GridLines="None">

<FooterStyle CssClass="ui_Datagrid_Style1_FooterStyle" />

<SelectedItemStyle CssClass="ui_Datagrid_Style1_SelectedItemStyle" />

<PagerStyle CssClass="ui_Datagrid_Style1_PagerStyle" Mode="NumericPages" />

<HeaderStyle CssClass="ui_Datagrid_Style1_HeaderStyle" />

<ItemStyle CssClass="ui_Datagrid_Style1_ItemStyle" />

<EditItemStyle CssClass="ui_Datagrid_Style1_EditItemStyle" />

<AlternatingItemStyle CssClass="ui_Datagrid_Style1_AlternatingItemStyle" />

<Columns>

<asp:TemplateColumn>

<HeaderStyle Width="9px"></HeaderStyle>

<ItemTemplate>

<asp:ImageButton id="ImageButton1" runat="server" Width="9px" Height="9px" ImageUrl="~/Images/Plus.gif"

CommandName="Expand"></asp:ImageButton>

</ItemTemplate>

</asp:TemplateColumn>

<asp:BoundColumn DataField="sItemId" HeaderText="Item ID" SortExpression="sItemId"></asp:BoundColumn>

<asp:BoundColumn DataField="sItemTypeId" HeaderText="Item Type" SortExpression="sItemTypeId">

</asp:BoundColumn>

<asp:BoundColumn DataField="nQtyOnHand" HeaderText="Quantity On Hand"></asp:BoundColumn>

<asp:TemplateColumn>

<ItemTemplate>

<asp:LinkButton ID="lnkbtnView" runat="server" CommandName="View" Text="View"></asp:LinkButton>

</ItemTemplate>

</asp:TemplateColumn>

<asp:TemplateColumn>

<ItemTemplate>

<asp:PlaceHolder ID="Expanded" Runat="server" Visible="False">

</td></tr>

<tr>

<td width="9">&nbsp;</td>

<td colspan="7">

<asp:DataGrid runat=server id=grdKit

CellPadding="2" BackColor="#f1f1f1" Font-Name="Verdana" Font-Size="8pt" AutoGenerateColumns=false ItemStyle-VerticalAlign="Top"

ShowFooter="True" AllowPaging="True" AllowSorting="True" EnableViewState=true>

<AlternatingItemStyle BackColor="White"></AlternatingItemStyle>

<HeaderStyle Font-Bold="True" HorizontalAlign="Center" ForeColor="White" BackColor="#0083C1"></HeaderStyle>

<Columns>

<asp:BoundColumn DataField="sItemId" HeaderText="Item ID" SortExpression="sItemId"></asp:BoundColumn>

<asp:BoundColumn DataField="sItemTypeId" HeaderText="Item Type" SortExpression="sItemTypeId">

</asp:BoundColumn>

<asp:BoundColumn DataField="nQtyOnHand" HeaderText="Quantity On Hand"></asp:BoundColumn>

<asp:TemplateColumn>

<ItemTemplate>

<asp:LinkButton ID="lnkbtnView" runat="server" CommandName="Edit" Text="View"></asp:LinkButton>

</ItemTemplate>

</asp:TemplateColumn>

</Columns>

<PagerStyle Mode="NumericPages"></PagerStyle>

</asp:DataGrid>

</asp:PlaceHolder>

</ItemTemplate>

</asp:TemplateColumn>

</Columns>

</asp:DataGrid>

</td>

</tr>

<tr>

<td align="left" style="height: 31px">

<asp:Button ID="btnAdd" runat="server" CssClass="button" Text="Add" />&nbsp;</td>

</tr>

</table>

</asp:Content>

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

The following is my .vb file :

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

If Page.IsPostBack = False Then

dt = dbConn.getInventory()

ViewState(
"vs_Inventory") = dt

grdData.DataSource = dt

grdData.DataBind()

Session.Item("Clicked") = "Search"

End If

searchInven()

Session.Remove(
"Clicked")

End Sub

Protected Sub grdData_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles grdData.ItemCommand

If e.CommandName.Equals("Edit") Then

MsgBox("here")

End If

If e.CommandName.Equals("View") Then

Dim objInventory As New ClsInventory

objInventory.ItemId = e.Item.Cells(1).Text

Session(
"dg_Inventory") = dbConn.getInventoryById(objInventory.ItemId)

Response.Redirect("adm_Inventory_Edit.aspx")

End If

End Sub

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

 

 

"Allen Chen – M
NewsGroup User
Re: Major Error doing a nested datagrid (VB)12/5/2007 6:01:03 AM

0

Hi:

  Please try:

<%@ Page EnableEventValidation="false"

  But please note this will decrease security.

Regards


Sincerely,
Allen Chen
Microsoft Online Community Support

Please remember to click ?Mark as Answer? on the post that helps you, and to click ?Unmark as Answer? if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

If my solution doesn't solve your problem, just feel free to mark it as not answer and reply.
"billylam" <>
NewsGroup User
Re: Major Error doing a nested datagrid (VB)12/5/2007 8:51:58 AM

0

i figure out the problem of it already. Thanks for the help. However this brings me to another problem. I will post the details of the problem i encounter in the next post.

3 Items, 1 Pages 1 |< << Go >> >|




   
  Privacy | Contact Us
All Times Are GMT