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.
Related
I just want to get the cell values from my GridView and place it in the different textboxes. I tried so many things but I just couldn't get it to work. Maybe you could help. Thanks.
This is the last thing I tried:
<asp:GridView ID="GridView1" runat="server" BackColor="#DEBA84" BorderColor="#DEBA84" BorderStyle="Solid" BorderWidth="1px" CellPadding="3" CellSpacing="2" AutoGenerateColumns="False" AutoGenerateSelectButton="True" onselectedindexchanged="GridView1_SelectedIndexChanged" OnSelectedIndexChanging="Gridview1_SelectedIndexChanging">
<Columns>
<asp:TemplateField ItemStyle-Width = "30px" HeaderText="Employee ID">
<ItemTemplate>
<asp:Label ID="lblEmpID" runat="server" Text='<%# Eval("emp_id") %>'></asp:Label>
</ItemTemplate>
<ItemStyle Width="30px"></ItemStyle>
</asp:TemplateField>
<asp:TemplateField HeaderText="Name">
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Eval("emp_name") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Address">
<ItemTemplate>
<asp:Label ID="Label3" runat="server" Text='<%# Eval("emp_add") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Contact Num.">
<ItemTemplate>
<asp:Label ID="Label4" runat="server" Text='<%# Eval("emp_contact") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Hire Date">
<ItemTemplate>
<asp:Label ID="Label5" runat="server" Text='<%# Eval("hire_date") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Branch ">
<ItemTemplate>
<asp:Label ID="Label6" runat="server" Text='<%# Eval("hire_date") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="#F7DFB5" ForeColor="#8C4510" />
<HeaderStyle BackColor="#A55129" Font-Bold="True" ForeColor="White" />
<PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" />
<RowStyle BackColor="#FFF7E7" ForeColor="#8C4510" />
<SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#FFF1D4" />
<SortedAscendingHeaderStyle BackColor="#B95C30" />
<SortedDescendingCellStyle BackColor="#F1E5CE" />
<SortedDescendingHeaderStyle BackColor="#93451F" />
</asp:GridView>
Code Behind:
protected void btnUpdate_Click(object sender, EventArgs e)
{
EmployeeDLL edll = new EmployeeDLL();
edll.Update_Employee(txtEmpID.Text, txtName.Text, txtAddress.Text, txtContact.Text, txtHireDate.Text, txtBranchID.Text);
lblStatus.Text = "Record has been updated.";
edll = null;
}
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
// txtEmpID.Text = GridView1.SelectedValue.ToString();
GridViewRow row = GridView1.SelectedRow;
txtEmpID.Text = row.Cells[0].Text;
txtName.Text = row.Cells[1].Text;
}
Use something like this
TextBox TextBoxLot = (TextBox)GridView1.Rows[rowIndex].Cells[1].FindControl("label");
When using <asp:TemplateField>, the data is not inside Cell but is contained in the Control present inside the Cell.
So, There are two steps to read the value:
Access the Control inside Cell
Access the Value from Control in step 1
Example:
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
GridViewRow row = GridView1.SelectedRow;
// Step 1: Access the Control inside Cell
Label lblEmpId = (Label)row.Cells[0].FindControl("lblEmpID");
// Step 2: Access the Value from Control in step 1
string value = lblEmpId.Text;
// Combine Step 1 & Step 2
string valueEmpID = ((Label)row.Cells[0].FindControl("lblEmpID")).Text;
string name = ((Label)row.Cells[0].FindControl("Label2")).Text;
}
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();
}
}
I have a dropdownlist and a gridview control. DropDownlist is outside the gridview.
Dropdownlist contains an option Delete.
Gridview contains checkbox so that rows can be selected.
here is the gridview code:
<asp:GridView ID="gvRefDetail" runat="server" CssClass="mGrid" AutoGenerateColumns="False"
PageSize="50" Font-Names="Segoe UI" Font-Size="10pt" Width="800" AllowPaging="true"
BackColor="White" BorderColor="Silver" EmptyDataText="No Record" BorderStyle="Double"
BorderWidth="1px" CellPadding="4">
<HeaderStyle BackColor="red" />
<RowStyle BackColor="White" ForeColor="#003399" />
<Columns>
<asp:TemplateField>
<HeaderTemplate>
<input id="Checkbox2" type="checkbox" onclick="CheckAll(this)" runat="server" /></HeaderTemplate>
<ItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="NameofReferred">
<ItemStyle Wrap="true" HorizontalAlign="Left" />
<ItemTemplate>
<asp:Label ID="lbltext" runat="server" Text='<%#Bind("NameofReferred") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txttext" runat="server" Text='<%#Bind("NameofReferred")%>'></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="CustomerName">
<ItemStyle Wrap="true" HorizontalAlign="Left" />
<ItemTemplate>
<asp:Label ID="lbltext" runat="server" Text='<%#Bind("CustomerName") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txttext" runat="server" Text='<%#Bind("CustomerName")%>'></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
</Columns>
<PagerStyle BackColor="#006699" Font-Bold="True" ForeColor="White" HorizontalAlign="Center" />
<AlternatingRowStyle BackColor="#CCFFFF" />
<SelectedRowStyle BackColor="#009999" Font-Bold="True" ForeColor="#CCFF99" />
<HeaderStyle BackColor="White" Font-Bold="True" ForeColor="Gray" BorderColor="Gray" />
<SelectedRowStyle BackColor="#009999" Font-Bold="True" ForeColor="#CCFF99" />
<HeaderStyle Font-Bold="True" ForeColor="White" />
</asp:GridView>
c# code:
protected void ddlaction_SelectedIndexChanged(object sender, EventArgs e)
{
if (ddlaction.SelectedValue == "1")
{
GridViewRow gvrow = gvRefDetail.SelectedRow;
int id = Convert.ToInt32(gvrow.Cells[1].Text);
string delref = "delete from tbl_Refferal where ID='" + id + "' ";
con = new SqlConnection(conString);
con.Open();
SqlCommand cmd2 = new SqlCommand(delref, con);
int temp1 = cmd2.ExecuteNonQuery();
con.Close();
BindRef();
}
}
Now, my question is when I select a one or more rows from gridview and select the delete option from dropdownlist, the selected rows must get deleted.
How can I do this?
Code On ddlaction_SelectedIndexChanged and stringVariableContainCheckboxvalues is string variable fetch from gridview checkbox selected in format ('1,3,5,6')
if (ddlaction.SelectedValue == "1")
{
string delref = "delete from tbl_Refferal where ID in (#checkboxSelectedValues)";
con = new SqlConnection(conString);
SqlCommand cmd2 = new SqlCommand(delref, con);
cmd2.Parameters.AddWithValue("#checkboxSelectedValues", stringVariableContainCheckboxvalues);
con.Open();
int temp1 = cmd2.ExecuteNonQuery();
con.Close();
BindRef();
}
Fetch Multiple Checkbox values:
foreach (GridViewRow row in gvRefDetail.Rows)
{
CheckBox cb = (CheckBox)row.FindControl("CheckBox1");
if (cb != null && cb.Checked)
{
// fetch values in string
}
}
i have a grid view inside update panel with multiple bound fields the last two bound field as shown in image when click show another grid view without post back but download not working except i set EnablePartialRendering="false" of script-manager
but in this case updatepanel not working to show bound field
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" >
<contenttemplate>
<div id="DivImages" runat="server" visible="false" class="block rnd">
<div class="title2">الأحكـــــــــــام</div>
<div class="content2">
<asp:gridview ID="GvImages" runat="server" PagerStyle-CssClass="pages" AllowPaging="True"
AutoGenerateColumns="False" CellSpacing="-1" Width="100%" DataKeyNames="DocCode,IssuesID"
CssClass="dataGrid" OnPageIndexChanging="GvImages_PageIndexChanging" GridLines="None"
PageSize="20" OnRowCommand="GvImages_RowCommand"
OnSelectedIndexChanging="GvImages_SelectedIndexChanging">
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:TemplateField HeaderText="رقم السجــل">
<ItemTemplate>
<%# Container.DataItemIndex + 1 %>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="DocCode" HeaderText="رقم الحكم/ القرار" SortExpression="DocCode" />
<asp:BoundField DataField="IssuesNum" HeaderText="كود القضيه"
SortExpression="IssuesNum" />
<asp:BoundField DataField="TypeName" HeaderText="نوع القضيه"
SortExpression="TypeName" />
<asp:BoundField DataField="Year" HeaderText="السنه"
SortExpression="Year" />
<asp:BoundField DataField="Area" HeaderText="المنطقه"
SortExpression="Area" />
<asp:BoundField DataField="DocTypeName" HeaderText="تصنيــف المستند" SortExpression="DocTypeName" />
<asp:BoundField DataField="Name" HeaderText="نوع المستند"
SortExpression="Name" />
<asp:TemplateField HeaderText="حذف">
<ItemTemplate>
<asp:LinkButton ID="cmd_DeleteRow" CommandName="DeleteRow" CssClass="delete" ToolTip="حذف" CommandArgument="<%# ((GridViewRow)Container).RowIndex %>" runat="server" OnClientClick="return confirmDeleteRow()" />
</ItemTemplate>
<HeaderStyle Width="125px" />
</asp:TemplateField>
<asp:CommandField SelectText="عرض" HeaderText="عرض" ShowHeader="True" ShowSelectButton="True">
<HeaderStyle HorizontalAlign="Right" />
</asp:CommandField>
<asp:TemplateField HeaderText="تحميل">
<ItemTemplate>
<asp:LinkButton ID="DownLoad" CommandName="DownLoad" Text="تحميل" ToolTip="تحميل" CommandArgument="<%# ((GridViewRow)Container).RowIndex %>" runat="server" />
</ItemTemplate>
<HeaderStyle Width="125px" />
</asp:TemplateField>
</Columns>
<RowStyle Height="25px" />
<HeaderStyle Height="30px" />
<PagerStyle CssClass="pages" Wrap="false" />
</asp:gridview>
</div>
</div>
</contenttemplate>
<Triggers>
in button search i bind my grid
like in this code
protected void ShowDoc(string sCondition)
{
//declare connection by pass connection string from web.config
SqlConnection sqlcon = new SqlConnection
(ConfigurationManager.ConnectionStrings["SystemConn"].ConnectionString);
//declare sql statment as astring variable
if (Session["Image"] != null)
{
Session.Remove("Image");
}
try
{
SqlStatment = string.Format("select distinct IssuesNum,DocType,DocTypeSub,DocCode,DocTypeName,Name,IssuesID,TypeID,TypeName,Area,IssuesNumSplited,Year from [View_ImagesSearch] Where {0} Order By [IssuesNumSplited] ASC", sCondition);
//create asql command and pass for it the connection string and sql statment
SqlCommand sqlcom = new SqlCommand(SqlStatment, sqlcon);
//create data adaptor to bring data from database
SqlDataAdapter sad = new SqlDataAdapter(sqlcom);
// declare dataset to store data from data base in it
DataSet ds = new DataSet();
//fill data set with data adabter that contain data from database
sad.Fill(ds);
lblDocCount2.Text = ds.Tables[0].Rows.Count.ToString();
Session["Image"] = ds;
GvImages.DataSource = ds;
GvImages.DataBind();
}
catch (Exception ex)
{
par_ErrorMessage.Visible = true;
par_ErrorMessage.InnerText = ex.Message;
}
}
when i click command called عرض updatepanel work to show another gridview
but when iclick item template download not workink fine untill i set EnablePartialRendering="False"
Make sure you are calling Update on the UpdatePanel after you call DataBind on the GridView:
GridView.DataBind();
UpdatePanel.Update();
See this for other possible solutions.
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.