public void FillHatcheryGridDetails()
{
try
{
DataTable dthatcherygrid = new DataTable();
dthatcherygrid = objhatcheryBAL.GetChickGridsdet();
GVChickSales.DataSource = dthatcherygrid;
GVChickSales.DataBind();
}
catch (Exception ex)
{
Log(ex.Message, ex.StackTrace);
ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "Exception Message", "alert('You have an exception,please consult IT department')", true);
}
}
protected void GVChickSales_RowDataBound(object sender, GridViewRowEventArgs e)
{
try
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
GridView GridView2 = (GridView)e.Row.FindControl("gvnested");
DataRowView rowView = (DataRowView)e.Row.DataItem;
int hatchid = Convert.ToInt32(rowView["hatchid"]);
DataTable dtRegions = new DataTable();
objhatcheryPL.hatchid = hatchid;
dtRegions = objhatcheryBAL.GetHatchidDetails(objhatcheryPL);
GridView2.DataSource = dtRegions;
GridView2.DataBind();
}
}
catch (Exception ex)
{
Log(ex.Message, ex.StackTrace);
ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "Exception Message", "alert('You have an exception,please consult IT department')", true);
}
}
protected void gvnested_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
try
{
System.Web.UI.WebControls.GridView gvnested = ((System.Web.UI.WebControls.GridView)sender);
gvnested.EditIndex = -1;
FillHatcheryGridDetails();
}
catch (Exception ex)
{
Log(ex.Message, ex.StackTrace);
ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "Exception Message", "alert('You have an exception,please consult IT department')", true);
}
}
protected void gv_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
}
protected void gvnested_RowEditing(object sender, GridViewEditEventArgs e)
{
try
{
System.Web.UI.WebControls.GridView gvnst = ((System.Web.UI.WebControls.GridView)sender);
gvnst.EditIndex = e.NewEditIndex;
}
catch (Exception ex)
{
Log(ex.Message, ex.StackTrace);
ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "Exception Message", "alert('You have an exception,please consult IT department')", true);
}
}
and this is my aspx source page..
<table width="80%" style="clear: both; float: none; margin-right: auto; margin-left: auto;
border: 2px solid white; font: 13px Verdana;">
<tbody>
<tr>
<th align="center" colspan="4">
Add Chicks
</th>
</tr>
<tr>
<td valign="top" align="center">
<br />
<input id="hid_hatchid" type="hidden" name="hddclick" runat="server" />
<asp:GridView ID="GVChickSales" runat="server" AutoGenerateColumns="false" DataKeyNames="hatchid"
OnRowCommand="GVChickSales_RowCommand" OnPageIndexChanging="GVChickSales_PageIndexChanging"
OnRowDataBound="GVChickSales_RowDataBound" BorderStyle="Solid" CssClass="center"
Style="width: 770px;" BorderWidth="1px" BorderColor="#BDBDBD" AllowPaging="true"
PageSize="10" EmptyDataText="No Record Found">
<Columns>
<asp:TemplateField ItemStyle-Width="20px">
<ItemTemplate>
<a href="java<!-- no -->script:divexpandcollapse('div<%# Eval("hatchid") %>');">
<img id='imgdiv<%# Eval("hatchid") %>' border="0" src="../kjl_images/closed.gif"
alt="Logo" />
</a>
</ItemTemplate>
<ItemStyle Width="20px"></ItemStyle>
</asp:TemplateField>
<asp:TemplateField HeaderText="SNo">
<ItemTemplate>
<span>
<%#Container.DataItemIndex + 1%>
</span>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="hatcheryname" HeaderText="Hatchery Name" ReadOnly="true">
</asp:BoundField>
<asp:BoundField DataField="Settingdate" HeaderText="Setting Date" ReadOnly="true">
</asp:BoundField>
<asp:BoundField DataField="Eggsdispatchqty" HeaderText="Eggs Dispatch Qty."></asp:BoundField>
<asp:BoundField DataField="Settingqty" HeaderText="Setting Qty."></asp:BoundField>
<asp:BoundField DataField="Pulloutdate" HeaderText="Pullout Date" ReadOnly="true">
</asp:BoundField>
<asp:BoundField DataField="flockno" HeaderText="Flock No"></asp:BoundField>
<asp:BoundField DataField="Noofchicks" HeaderText="ChicksQty."></asp:BoundField>
<asp:BoundField DataField="Culls" HeaderText="Culls"></asp:BoundField>
<asp:BoundField DataField="ActSalablechicks" HeaderText="Actual Saleablechicks" ReadOnly="true">
</asp:BoundField>
<asp:BoundField DataField="Salablechicks" HeaderText="Saleablechicks"></asp:BoundField>
<asp:TemplateField HeaderText="Add Sales">
<ItemTemplate>
<asp:LinkButton ID="lnksales" runat="server" CommandName="ADDSALES" CommandArgument="<%#Container.DataItemIndex%>"
Text="Add" ForeColor="Blue">
</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Chick Sales Close">
<ItemTemplate>
<asp:LinkButton ID="lnkclose" runat="server" CommandName="CLOSESALES" CommandArgument="<%#Container.DataItemIndex%>"
Text="Close" ForeColor="Blue">
</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<tr>
<td colspan="100%">
<div id='div<%# Eval("hatchid") %>' style="display: none; position: relative; left: 50px;
overflow: auto">
<asp:GridView ID="gvnested" BorderColor="#df5015" CssClass="center" Style="width: 770px;"
DataKeyNames="sno" runat="server" AutoGenerateColumns="false" OnRowCancelingEdit="gvnested_RowCancelingEdit"
OnRowEditing="gvnested_RowEditing" OnRowDeleting="gv_RowDeleting" OnRowCommand="gvnested_RowCommand"
OnRowUpdating="gvnested_RowUpdating">
<%-- <HeaderStyle BackColor="#993366" Font-Bold="true" ForeColor="White" />--%>
<RowStyle BackColor="#E1E1E1" />
<AlternatingRowStyle BackColor="White" />
<Columns>
<%-- <asp:BoundField DataField="name" HeaderText="Name" HeaderStyle-HorizontalAlign="Center" />--%>
<asp:TemplateField HeaderText="Name">
<ItemTemplate>
<asp:Label ID="lbl_rate1" runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"name") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox runat="server" ID="txtrate7" Width="90px" onkeypress="return validatenumerics(event);"
Text='<%#DataBinder.Eval(Container.DataItem,"name") %>'></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText=" Date">
<ItemTemplate>
<asp:Label ID="lbl_rate2" runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"Date") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox runat="server" ID="txtrate6" Width="90px" onkeypress="return validatenumerics(event);"
Text='<%#DataBinder.Eval(Container.DataItem,"Date") %>'></asp:TextBox>
</EditItemTemplate>
<EditItemTemplate>
<asp:TextBox runat="server" ID="txt_date" Width="90px"></asp:TextBox>
<asp:CalendarExtender ID="calrecdate" runat="server" TargetControlID="txt_date" OnClientDateSelectionChanged="checkDate"
Format="dd/MM/yyyy" Enabled="True" />
<asp:RequiredFieldValidator ID="RFVrecdate" runat="server" ControlToValidate="txt_date"
Display="None" ErrorMessage="Must Enter Received Date" ValidationGroup="duereport"></asp:RequiredFieldValidator>
<asp:ValidatorCalloutExtender ID="VCErecdate" runat="Server" TargetControlID="RFVrecdate" />
</EditItemTemplate>
</asp:TemplateField>
<%--<asp:BoundField DataField="Date" HeaderText="Date" HeaderStyle-HorizontalAlign="Center" />--%>
<%-- <asp:BoundField DataField="chicksqty" HeaderText="ChickQty" HeaderStyle-HorizontalAlign="Center" />--%>
<asp:TemplateField HeaderText=" ChickQty">
<ItemTemplate>
<asp:Label ID="lbl_rate3" runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"chicksqty") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox runat="server" ID="txtrate5" Width="90px" onkeypress="return validatenumerics(event);"
Text='<%#DataBinder.Eval(Container.DataItem,"chicksqty") %>'></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<%-- <asp:BoundField DataField="mortality" HeaderText="Mortality" HeaderStyle-HorizontalAlign="Center" />--%>
<asp:TemplateField HeaderText="Mortality">
<ItemTemplate>
<asp:Label ID="lbl_rate4" runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"mortality") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox runat="server" ID="txtrate4" Width="90px" onkeypress="return validatenumerics(event);"
Text='<%#DataBinder.Eval(Container.DataItem,"mortality") %>'></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<%--<asp:BoundField DataField="Billeablechicks" HeaderText="Billable Chicks" HeaderStyle-HorizontalAlign="Center" />--%>
<asp:TemplateField HeaderText="Billablechicks">
<ItemTemplate>
<asp:Label ID="lbl_rate5" runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"Billeablechicks") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox runat="server" ID="txtrate3" Width="90px" onkeypress="return validatenumerics(event);"
Text='<%#DataBinder.Eval(Container.DataItem,"Billeablechicks") %>'></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<%--<asp:BoundField DataField="Boardrate" HeaderText="Board Rate" HeaderStyle-HorizontalAlign="Center" />--%>
<%--<asp:BoundField DataField="chickrate" HeaderText="Chick Rate" HeaderStyle-HorizontalAlign="Center" />--%>
<asp:TemplateField HeaderText="chickrate">
<ItemTemplate>
<asp:Label ID="lbl_rate6" runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"chickrate") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox runat="server" ID="txtrate2" Width="90px" onkeypress="return validatenumerics(event);"
Text='<%#DataBinder.Eval(Container.DataItem,"chickrate") %>'></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText=" Board Rate">
<ItemTemplate>
<asp:Label ID="lbl_rate7" runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"Boardrate") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox runat="server" ID="txtrate1" Width="90px" onkeypress="return validatenumerics(event);"
Text='<%#DataBinder.Eval(Container.DataItem,"Boardrate") %>'></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:CommandField ControlStyle-ForeColor="Blue" ShowEditButton="true" HeaderText="Edit" />
<asp:TemplateField HeaderText="Delete">
<ItemTemplate>
<asp:LinkButton ID="lnkDelete" runat="server" CommandArgument="<%#Container.DataItemIndex%>"
CommandName="Delete" ForeColor="Blue" OnClientClick="return confirm("Are you sure you want to delete?");"
Text="Delete">
</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
</td>
</tr>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</td>
</tr>
</tbody>
</table>
please help me...how to solve this..