I try to bind data from code behind into a GridView. I don't know what's wrong cause there is no error from debug, but when I try to display the page in browser it doesn't display (the hole page won't come up).
<asp:GridView runat="server" ID="productCart" AutoGenerateColumns="false" EmptyDataText="There is nothing in your shopping cart." GridLines="None" Width="100%" CellPadding="5" ShowFooter="true" DataKeyNames="ProductId">
<HeaderStyle HorizontalAlign="Left" BackColor="#F36EA7" ForeColor="#FFFFFF" />
<FooterStyle HorizontalAlign="Right" BackColor="#6C6B66" ForeColor="#FFFFFF" />
<AlternatingRowStyle BackColor="#F8F8F8" />
<Columns>
<asp:BoundField DataField="Description" HeaderText="Description" />
<asp:TemplateField HeaderText="Quantity">
<ItemTemplate>
<asp:TextBox runat="server" ID="txtQuantity" Columns="5" Text='<%# Eval("Quantity") %>'></asp:TextBox><br />
<asp:LinkButton runat="server" ID="btnRemove" Text="Remove" CommandName="Remove" CommandArgument='<%# Eval("ProductId") %>' style="font-size:12px;"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="UnitPrice" HeaderText="Price" ItemStyle-HorizontalAlign="Right" HeaderStyle-HorizontalAlign="Right" DataFormatString="{0:C}" />
<asp:BoundField DataField="TotalPrice" HeaderText="Total" ItemStyle-HorizontalAlign="Right" HeaderStyle-HorizontalAlign="Right" DataFormatString="{0:C}" />
</Columns>
</asp:GridView>
.cs:
public partial class Cart : System.Web.UI.Page
{
UserSingleton activeUser = UserSingleton.Instance;
List<CartItem_Test> CartItems = null;
protected void Page_Load(object sender, EventArgs e)
{
DataTable dataTable = Access.GetInfo("CartPerUserID", "*", "UserID=" + activeUser.get_user().ID);
if (dataTable.Rows.Count > 0)
{
CartItems = new List<CartItem_Test>(dataTable.Rows.Count);
foreach (DataRow row in dataTable.Rows)
{
CartItem_Test cartItem = new CartItem_Test(row);
CartItems.Add(cartItem);
}
}
if (!IsPostBack)
{
productCart.DataSource = CartItems;
productCart.DataBind();
}
}
Related
I am trying to change the image displayed on the image button based on the value of a cell on a GridView . I tried the following :
<asp:GridView ID="grd_UserDetails" runat="server" AllowPaging="True" AutoGenerateColumns="False"
GridLines="None" Width="600px" CellPadding="4" ForeColor="#333333" OnPageIndexChanging="grd_UserDetails_PageIndexChanging" OnSelectedIndexChanged="grd_UserDetails_SelectedIndexChanged">
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<Columns>
<asp:BoundField DataField="userId" HeaderText="UserId" ><ItemStyle HorizontalAlign="Center" /></asp:BoundField>
<asp:BoundField DataField="password" HeaderText="Password" ><ItemStyle HorizontalAlign="Center" /></asp:BoundField>
<asp:BoundField DataField="username" HeaderText="UserName" ><ItemStyle HorizontalAlign="Center" /></asp:BoundField>
<asp:BoundField DataField="email" HeaderText="Email Id" ></asp:BoundField>
<asp:BoundField DataField="status" HeaderText="Status" SortExpression="Active" />
<asp:TemplateField>
<ItemTemplate>
<asp:ImageButton ID="img_user" runat="server" CommandName="Select"
ImageUrl='<%# Eval("status") %>' Width="20px" Height="20px" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
codebehind :
protected void grd_UserDetails_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
ImageButton img = (ImageButton)e.Row.FindControl("img_user");
if (e.Row.Cells[4].Text == "Active")
{
img.ImageUrl = "~/images/active.png ";
}
else
{
img.ImageUrl = "~/images/inactive.png ";
}
}
}
But the image button is not displaying any image .How do i fix this. My images seem to be placed correctly in the root .
Remove ImageUrl='<%# Eval("status") %>' in aspx file.
In aspx.cs file, please try as below.
(I assume gridview cell[4]'s data filed name is "Status").
ImageButton img = (ImageButton)e.Row.FindControl("img_user");
string status = (string)DataBinder.Eval(e.Row.DataItem, "Status");
img.ImageUrl = status == "Active" ? "~/images/active.png" : "~/images/inactive.png ";
My scenario is : I have one dataGrid with 5-6 columns. i have 3 filters which use 3 SQL queries methods in codeBehind :SearchByName(), SearchByValue() , SearchByDate().I have fourth method show DefaultShow() which display all data without any filters.
Basicly I want when Page is loaded DefaultShow() method to load and then user can choose option for search with RadioButtonList
DefaultShow() code is :
public void DefaultShow()
{
string connectionString = cs.getConnection();
string query = "select Id ,name,value,Description,DateCreate from AllCostView where IdUser = '" + cui.getCurrentId() + "'";
using (SqlConnection myConnection = new SqlConnection(connectionString))
{
myConnection.Open();
SqlCommand command = new SqlCommand(query, myConnection);
SqlDataAdapter mySqlAdapter = new SqlDataAdapter(command);
using (DataTable myDataTable = new DataTable())
{
mySqlAdapter.Fill(myDataTable);
GridViewCost.DataSource = myDataTable;
GridViewCost.DataBind();
}
}
}
protected void Page_Load(object sender, EventArgs e)
{
DefaultShow();
}
But this not work what am I miss?
My gridViewCode is this :
<div class ="gridView">
<asp:GridView ID="GridViewCost" runat="server" AutoGenerateColumns="False" CaptionAlign="Top"
ShowFooter="True" ShowHeaderWhenEmpty="True" Font-Overline="False"
Font-Strikeout="False" Font-Underline="False"
AllowPaging="true"
PageSize="5"
CssClass="mGrid"
PagerStyle-CssClass="pgr"
AlternatingRowStyle-CssClass="alt" OnPageIndexChanging="GridViewCost_PageIndexChanging" OnSelectedIndexChanged="RadioButtonList1_SelectedIndexChanged" >
<AlternatingRowStyle CssClass="alt"></AlternatingRowStyle>
<Columns>
<asp:BoundField DataField="Id" HeaderText="Номер" />
<asp:TemplateField HeaderText="Име">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Name") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("Name") %>'></asp:Label>
</ItemTemplate>
<ControlStyle Width="100px" />
</asp:TemplateField>
<asp:BoundField DataField="Value" HeaderText="Стойност" />
<asp:BoundField DataField="Description" HeaderText="Описание" />
<asp:BoundField DataField="DateCreate" HeaderText="Дата" />
</Columns>
<AlternatingRowStyle />
<HeaderStyle HorizontalAlign="Right"/>
<PagerStyle />
<RowStyle BorderColor="Black" BorderStyle="Solid" BorderWidth="1px" HorizontalAlign="Center" />
</asp:GridView>
If it's needed i will post more code . Thanks.
Hello I'm doing a school project and I'm stuck on a problem any help would be great
i have a Shopping Cart Gridview that has a text box quantity where a user can change quantity value for some reason it is not getting the new value just the old value thank you!
<div class="container">
<h1>Shopping Cart</h1>
< Back to Products
<br /><br />
<asp:Label ID="Label2" runat="server" ></asp:Label>
<asp:Label ID="Label3" runat="server" ></asp:Label>
<asp:GridView runat="server" ID="gvShoppingCart" AutoGenerateColumns="false" EmptyDataText="There is nothing in your shopping cart." GridLines="None" Width="100%" CellPadding="5" ShowFooter="true" DataKeyNames="ProductID" OnRowDataBound="gvShoppingCart_RowDataBound" OnRowDeleting="grdCart_RowDeleting" >
<HeaderStyle HorizontalAlign="Left" BackColor="#3D7169" ForeColor="#FFFFFF" />
<FooterStyle HorizontalAlign="Right" BackColor="#6C6B66" ForeColor="#FFFFFF" />
<AlternatingRowStyle BackColor="#F8F8F8" />
<Columns>
<asp:BoundField DataField="ProductName" HeaderText="Brand" />
<asp:TemplateField HeaderText="Quantity">
<ItemTemplate>
<asp:TextBox runat="server" ID="txtQuantity" Columns="5" Text='<%# Eval("Quantity") %>'></asp:TextBox><br />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Price" HeaderText="Price" ItemStyle-HorizontalAlign="Right" HeaderStyle-HorizontalAlign="Right" DataFormatString="{0:C}" />
<asp:BoundField DataField="SubTotal" HeaderText="Total" ItemStyle-HorizontalAlign="Right" HeaderStyle-HorizontalAlign="Right" DataFormatString="{0:C}" />
<asp:CommandField ShowDeleteButton="True" />
</Columns>
</asp:GridView>
<br />
<asp:Button runat="server" ID="btnUpdateCart" Text="Update Cart" OnClick="btnUpdateCart_Click" /><br />
<asp:Button ID="btnClose2" runat="server" Text="Close" Width="50px" />
</div>
The code behind
protected void btnUpdateCart_Click(object sender, EventArgs e)
{
foreach (GridViewRow row in gvShoppingCart.Rows)
{
if (row.RowType == DataControlRowType.DataRow)
{
// We'll use a try catch block in case something other than a number is typed in
// If so, we'll just ignore it.
try
{
// Get the productId from the GridView's datakeys
int productId = Convert.ToInt32(gvShoppingCart.DataKeys[row.RowIndex].Value);
Label2.Text = productId.ToString();
// Find the quantity TextBox and retrieve the value
int quantity = int.Parse(((TextBox)row.Cells[1].FindControl("txtQuantity")).Text);
Label3.Text = quantity.ToString();
ShoppingCart.Cart.Instance.SetItemQuantity(productId, quantity);
BindData();
}
catch (FormatException) { }
}
}
mpe2.Show();
}
I assume that you're databinding the GridView also on postbacks. You should do that only when !Page.IsPostBack:
if(!IsPostBack) BindGrid();
Apart from that, if you use a TemplateField, you should use FindControl to get a reference to your control:
var txtQuantity = (TextBox)row.FindControl("txtQuantity");
int quantity = int.Parse(txtQuantity.Text);
Sidenote: You dont need to check for DataControlRowType.DataRow when iterating the GridView rows(unlike in RowCreated or RowDataBound).
I've got a gridview inside an update panel.
In the gridview I have an image button.
The button is used to delete a row.
In the rowCommand event of the grid view I do something like this:
protected void gvLineItems_RowCommand(object sender, GridViewCommandEventArgs e)
{
GridViewRow row = (GridViewRow)((Control)e.CommandSource).NamingContainer;
switch (e.CommandName)
{
case "Delete":
Label l = null;
l = (Label)row.FindControl("lblLineItemID");
if(l!=null)
{
long lID;
lID = Convert.ToInt64(l.Text);
BL.DeleteLineItem(Convert.ToInt64(hlID.Text), lID);
BindGrid(Session["SortExpression"].ToString(), Convert.ToInt32(rbSortGrid.SelectedValue));
}
break;
}
}
I debug this and I see the row deleted in the database (data is deleted correctly). But the gridview still shows the "deleted" row even after bind grid. Bind grid is simple it looks like this:
protected void BindGrid(string sortExpression, int sortDirection)
{
DataSet ds
ds = BL.GetLineItemGridData(Convert.ToInt64(hlID.Text), sortExpression, sortDirection);
gvLineItems.DataSource = ds.Tables[0];
gvLineItems.DataBind();
gvLineItems.Visible = true;
}
The dataset is returning the correct rows (without the deleted row) but when I look at the webpage it still shows the row that was deleted.
Edit
Someone asked for the HTML of the gridview, here it is:
<asp:UpdatePanel ID="myPanel" runat="server" UpdateMode="Always">
<ContentTemplate>
<asp:GridView GridLines="Horizontal" CellPadding="4" Font-Size="Small"
DataKeyNames="ID" Width="100%" AlternatingRowStyle-BackColor="#e5f1fa"
BackColor="#E8E8E8" HeaderStyle-ForeColor="White"
HeaderStyle-BackColor="#1367AD" ID="gvLineItems" runat="server"
AllowSorting="True" AutoGenerateColumns="False" ShowFooter="True"
onrowcommand="gvLineItems_RowCommand" >
<Columns>
<asp:TemplateField>
<ItemStyle Width="1px" />
<ItemTemplate>
<asp:Label Width=".05px" ID="lblLineItemID" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.ID") %>' style="display:none"></asp:Label>
</ItemTemplate>
<ControlStyle Width="0px" />
<HeaderStyle Width="0px" />
</asp:TemplateField>
<asp:TemplateField>
<HeaderTemplate>
<asp:CheckBox ToolTip="Select / Deselect all rows?" ID="HeaderLevelCheckBox" onclick="toggleSelection(this);" runat="server" />
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox ID="chkSelector" ToolTip="Select row?" runat="server" onclick="ChangeRowColor(this)" />
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" />
<HeaderStyle HorizontalAlign="Center" />
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:ImageButton ID="ibAddLineItem" runat="server" ImageUrl="images/InsertRow.gif" CommandName="Insert" ToolTip="Insert new line item."/>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:ImageButton ID="ibDeleteLineItem" runat="server" ImageUrl="images/DeleteRow.gif" CommandName="Delete" ToolTip="Delete line item."/>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Item #" SortExpression="LineItemNumber">
<ItemTemplate>
<asp:Label runat="server" ID="lblItemNumber" Visible="True" Text='<%# DataBinder.Eval(Container, "DataItem.LineItemNumber") %>' />
</ItemTemplate>
<ItemStyle Width="10%" HorizontalAlign="Center" />
<HeaderStyle HorizontalAlign="Center" Width="10%" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Quantity" SortExpression="LineItemQuantity">
<ItemTemplate>
<asp:TextBox Font-Names="Arial" ToolTip="Enter item quantity." ID="txtLineItemQuantity" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.LineItemQuantity") %>' />
</ItemTemplate>
<ItemStyle Width="4%" HorizontalAlign="Center" />
<HeaderStyle HorizontalAlign="Center" Width="4%" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Description" SortExpression="LineItemDescription">
<ItemTemplate>
<asp:TextBox Columns="15" Width="300px" Font-Names="Arial" ToolTip="Enter item description." ID="txtLineItemDescription" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.LineItemDescription") %>' />
</ItemTemplate>
<ItemStyle Width="15%" HorizontalAlign="Left" />
<HeaderStyle HorizontalAlign="Left" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Added By" SortExpression="AddedBy">
<ItemTemplate>
<asp:Label runat="server" ID="lblAddedBy" Visible="True" Text='<%# DataBinder.Eval(Container, "DataItem.AddedBy") %>' />
</ItemTemplate>
<ItemStyle Width="10%" HorizontalAlign="Center" />
<HeaderStyle HorizontalAlign="Center" Width="10%" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Added On" SortExpression="AddedOn">
<ItemTemplate>
<asp:Label runat="server" ID="lblAddedOn" Visible="True" Text='<%# DataBinder.Eval(Container, "DataItem.AddedOn") %>' />
</ItemTemplate>
<ItemStyle Width="10%" HorizontalAlign="Center" />
<HeaderStyle HorizontalAlign="Center" Width="10%" />
</asp:TemplateField>
</Columns>
</asp:GridView>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnAddLineItem" />
<asp:AsyncPostBackTrigger ControlID="rbSortGrid" />
</Triggers>
</asp:UpdatePanel>
Err I got it I just added this:
protected void gvLineItems_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
DataSet ds = null;
gvLineItems.DataSource = null;
ds = BL.GetLineItemGridData(Convert.ToInt64(hlID.Text), Session["SortExpression"].ToString(), Convert.ToInt32(rbSortGrid.SelectedValue));
gvLineItems.DataSource = ds.Tables[0];
gvLineItems.DataBind();
gvLineItems.Visible = true;
}
And removed the call to BindGrid from this:
protected void gvLineItems_RowCommand(object sender, GridViewCommandEventArgs e)
{
GridViewRow row = (GridViewRow)((Control)e.CommandSource).NamingContainer;
switch (e.CommandName)
{
case "Delete":
Label l = null;
l = (Label)row.FindControl("lblLineItemID");
if(l!=null)
{
long lID;
lID = Convert.ToInt64(l.Text);
BL.DeleteLineItem(Convert.ToInt64(hlID.Text), lID);
//BindGrid(Session["SortExpression"].ToString(), Convert.ToInt32(rbSortGrid.SelectedValue));
}
break;
}
}
Alternatively you can bind your GridView in the Page PreRender event which occurs after processing of control events has been completed. You don't need to hook up the datasource and bind the grid in the rowCommand event then.
Hi all I am doing a program with a nested gridview my design is as follows
<asp:Panel CssClass="grid" ID="pnlCust" runat="server">
<asp:UpdatePanel ID="pnlUpdate" runat="server">
<ContentTemplate>
<asp:GridView AllowPaging="True" ID="gvCustomers" AutoGenerateColumns="False" DataKeyNames="EmpID"
runat="server" ShowHeader="true" BackColor="White" BorderColor="#DEDFDE" BorderStyle="None"
BorderWidth="1px" CellPadding="4" ForeColor="Black" GridLines="Vertical" >
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Panel CssClass="group" ID="pnlCustomer" runat="server">
<%--<asp:Image ID="imgCollapsible" CssClass="first" ImageUrl="~/Assets/img/plus.png"
Style="margin-right: 5px;" runat="server" /><span class="header">
<%#Eval("EmpID")%>
:
<%#Eval("empname")%>--%>
<asp:RadioButton ID="rdbtn" runat="server" onclick="RadioCheck(this);" OnCheckedChanged="radio_changed" Text='<%# Bind("EmpID") %>'
AutoPostBack="true"></asp:RadioButton>
</asp:Panel>
<asp:Panel Style="margin-left: 20px; margin-right: 20px" ID="pnlOrders" runat="server">
<asp:GridView AutoGenerateColumns="false" CssClass="grid" ID="gvOrders" runat="server"
PageSize="1" ShowHeader="true" EnableViewState="false" DataKeyNames="EmpID" AllowPaging="true"
OnPageIndexChanging="gvOrders_PageIndexChanging">
<RowStyle CssClass="row" />
<AlternatingRowStyle CssClass="altrow" />
<Columns>
<asp:BoundField HeaderText="Employee Id" DataField="EmpID">
<ItemStyle HorizontalAlign="Center" Width="100px" />
</asp:BoundField>
<asp:TemplateField ItemStyle-CssClass="rownum">
<ItemTemplate>
<%# Container.DataItemIndex + 1 %>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderStyle-BackColor="#EFF1F1" ItemStyle-HorizontalAlign="Center"
ItemStyle-Height="25" HeaderStyle-Width="50" ItemStyle-Width="50">
<HeaderTemplate>
<input id="chkBoxAll" type="checkbox" onclick="checkAllBoxes()" />
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox ID="chkBoxChild" runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="PayPeriodNumber" HeaderText="PayPeriod" HeaderStyle-BackColor="#EFF1F1"
ItemStyle-HorizontalAlign="Center" HeaderStyle-Width="80" ItemStyle-Width="80">
</asp:BoundField>
<asp:BoundField DataField="PayRollYear" HeaderText="Payroll Year" HeaderStyle-BackColor="#EFF1F1"
ItemStyle-HorizontalAlign="Center" HeaderStyle-Width="100" ItemStyle-Width="100">
</asp:BoundField>
<asp:BoundField DataField="PaymentDate" HeaderText="Payment Date" HeaderStyle-BackColor="#EFF1F1"
ItemStyle-HorizontalAlign="Center" HeaderStyle-Width="110" ItemStyle-Width="110">
</asp:BoundField>
</Columns>
</asp:GridView>
</asp:Panel>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="#CCCC99" />
<HeaderStyle BackColor="#6B696B" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#F7F7DE" ForeColor="Black" HorizontalAlign="Right" />
<RowStyle BackColor="#F7F7DE" />
<SelectedRowStyle BackColor="#CE5D5A" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#FBFBF2" />
<SortedAscendingHeaderStyle BackColor="#848384" />
<SortedDescendingCellStyle BackColor="#EAEAD3" />
<SortedDescendingHeaderStyle BackColor="#575357" />
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Panel>
Image of that on Page load
On selecting one of the radio buttons I will show the corresponding Employee details which is as follows
I have written paging for gridview as follows
if (!Page.IsPostBack)
{
GridViewChildPageIndex();
}
private void GridViewChildPageIndex()
{
DataTable dtPageIndex = new DataTable();
dtPageIndex.Columns.Add("PageIndex", typeof(int));
for (int i = 0; i < gvCustomers.Rows.Count; i++)
{
dtPageIndex.Rows.Add("0");
}
Session["ChildPageIndex"] = dtPageIndex;
}
Paging code of child gridview is as follows
protected void gvOrders_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView gvwChild = (GridView)sender;
//GridViewRow gvRowParent = ((System.Web.UI.WebControls.GridView)sender).Parent as GridViewRow;
GridViewRow gvRowParent = gvwChild.Parent as GridViewRow;
gvwChild.PageIndex = e.NewPageIndex;
if (Session["ChildPageIndex"] != null)
{
DataTable dtPageIndex = (DataTable)Session["ChildPageIndex"];
dtPageIndex.Rows[gvRowParent.RowIndex][1] = e.NewPageIndex; // *I am getting error here as Object reference not set to an Object can any one tell where I went wrong*
}
BindChildGrdView(gvCustomers.DataKeys[gvRowParent.RowIndex].Value.ToString(), gvwChild);
}
Stack Trace
at _Default.gvOrders_PageIndexChanging(Object sender, GridViewPageEventArgs e) in d:\Projects\GridView-Collapsible\GridView-Collapsible\Default.aspx.cs:line 54
at System.Web.UI.WebControls.GridView.OnPageIndexChanging(GridViewPageEventArgs e)
at System.Web.UI.WebControls.GridView.HandlePage(Int32 newPage)
at System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup)
at System.Web.UI.WebControls.GridView.RaisePostBackEvent(String eventArgument)
at System.Web.UI.WebControls.GridView.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
This may help you out:
In the gvOrders_PageIndexChanging function, use
GridViewRow gvRowParent = gvwChild.Parent.Parent as GridViewRow;
And inside the if condition
if (Session["ChildPageIndex"] != null)
{
DataTable dtPageIndex = (DataTable)Session["ChildPageIndex"];
dtPageIndex.Rows[gvRowParent.RowIndex][0] = e.NewPageIndex; // *I am getting error here as Object reference not set to an Object can any one tell where I went wrong*
}
And also could you debug and check if gvRowParent is an instantiated object in the second line of this function.