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);
}
}</pre>
这是我的aspx源页面..
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<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="JavaScript: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>
<br />
<ajaxToolkit:ModalPopupExtender ID="MPESales" runat="server" TargetControlID="Hidden1"
PopupControlID="panSales" RepositionMode="RepositionOnWindowResizeAndScroll"
BackgroundCssClass="modalBackground" CancelControlID="btnxcancel" PopupDragHandleControlID="panSales" />
<asp:Panel ID="panSales" runat="server" CssClass="ModalWindow" Style="overflow: scroll;
height: 470px; width: 1035px;">
<asp:Panel ID="pnlHatchHeader" runat="server" Width="550px">
<table>
<tr>
<td align="right">
<a href="/">
<img src="../kjl_images/btn_x.gif" id="btnxcancel" alt="Close" width="56px" height="18px"
border="0" /></a>
</td>
</tr>
</table>
</asp:Panel>
<table width="100%" style="clear: both; float: none; margin-right: auto; margin-left: auto;
border: 2px solid #BDBDBD;">
<caption>
<br />
<tr align="center">
<td colspan="2" align="center">
Sales :
<asp:DropDownList ID="DDLSalestype" runat="server" Style="width: 156px;">
<asp:ListItem Value="0">--Select--</asp:ListItem>
<asp:ListItem Value="1">Farmer Sales</asp:ListItem>
<asp:ListItem Value="2">Agent Sales</asp:ListItem>
<asp:ListItem Value="3">Integration</asp:ListItem>
</asp:DropDownList>
<asp:ImageButton ID="ChickSalesclick" runat="server" ImageUrl="~/kjl_images/gobutton_blue.gif"
OnClick="ChickSalesclick_Click" />
</td>
</tr>
<input id="Hidden1" runat="server" name="hddclick" type="hidden" />
</caption>
</table>
<br />
<br />
<asp:Panel ID="pnlFarmersales" runat="server">
<table width="80%" style="clear: both; float: none; margin-right: auto; margin-left: auto;
border: 2px solid #BDBDBD; font: 13px Verdana;">
<tr>
<td colspan="4" align="center">
<font size="2px"><b>
<asp:Label ID="lbltype" runat="server"></asp:Label></b></font>
</td>
</tr>
<tr>
<td>
Name :
</td>
<td>
<asp:Panel ID="pnlfarmername" runat="server" Width="110px">
<asp:DropDownList ID="ddlfarmername" runat="server" MaxLength="40">
</asp:DropDownList>
</asp:Panel>
<asp:Panel ID="pnlagentname" runat="server">
<asp:DropDownList ID="ddlagentname" runat="server">
</asp:DropDownList>
</asp:Panel>
<asp:Panel ID="pnlintegration" runat="server">
<asp:DropDownList ID="ddlintegrationfarmer" runat="server" MaxLength="40">
</asp:DropDownList>
</asp:Panel>
</td>
<td>
No of Chicks :
</td>
<td>
<asp:TextBox ID="txtNoofchicks" runat="server" MaxLength="6" onkeypress="return isNumberKey(event);"></asp:TextBox>
</td>
</tr>
<tr>
<td>
Chicks Placed Date :
</td>
<td>
<asp:TextBox ID="txtChicksdate" runat="server" onkeypress="return IsValidDateTime();"></asp:TextBox>
<asp:CalendarExtender ID="calldeliverydate" runat="server" TargetControlID="txtChicksdate"
OnClientDateSelectionChanged="checkDate" Format="dd/MM/yyyy" Enabled="True" />
<%--<asp:ImageButton ID="imgcal" runat="server" ImageUrl="~/kjl_images/Calendar.png" />
<ajaxToolkit:CalendarExtender ID="Calchicksdate" OnClientDateSelectionChanged="checkDate"
runat="server" PopupButtonID="imgcal" TargetControlID="txtChicksdate" Format="dd/MM/yyyy"
Enabled="True" />--%>
</td>
<td>
Transit Mortality :
</td>
<td>
<asp:TextBox ID="txtmortality" MaxLength="6" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
Weak Chicks:
</td>
<td>
<asp:TextBox ID="txtweakchicks" runat="server" onkeypress="return isNumberKey(event);"></asp:TextBox>
</td>
<td>
Returned Chicks:
</td>
<td>
<asp:TextBox ID="txtreturnedchicks" runat="server" onkeypress="return isNumberKey(event);"></asp:TextBox>
</td>
</tr>
<tr>
<td>
Free Chicks% :
</td>
<td>
<asp:TextBox ID="txtfreechicks" MaxLength="6" onkeyup="return Billablechicks(event);"
runat="server" onkeypress="return validatenumerics(event);"></asp:TextBox>
</td>
<td>
Billable Chicks :
</td>
<td>
<asp:TextBox ID="txtbillable" runat="server" MaxLength="6" onkeypress="return validatenumerics(event);"></asp:TextBox>
</td>
</tr>
<tr>
<td>
Rate Per Chick :
</td>
<td>
<asp:TextBox ID="txtRateperchick" MaxLength="6" onkeyup="return MakeTotalamount(event);"
runat="server"></asp:TextBox>
</td>
<td>
Board Rate:
</td>
<td>
<asp:TextBox ID="txtboardrate" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
Total Amount:
</td>
<td>
<asp:TextBox ID="txttamount" MaxLength="7" ReadOnly="true" runat="server"></asp:TextBox>
</td>
<td>
Amount Received :
</td>
<td>
<asp:TextBox ID="txtCashreceived" MaxLength="7" onkeyup="return Makeamountdue(event);"
runat="server" onkeypress="return validatenumerics(event);"></asp:TextBox>
</td>
</tr>
<tr>
<td>
DCNo :
</td>
<td>
<asp:TextBox ID="txtDcno" MaxLength="10" runat="server"></asp:TextBox>
</td>
<td>
Amount Due :
</td>
<td>
<asp:TextBox ID="txtamountdue" ReadOnly="true" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td colspan="4">
</td>
</tr>
<tr>
<td colspan="4" align="center">
<asp:Button ID="btnSave" runat="server" Text="Save" OnClientClick="return Validations();"
OnClick="btnSave_Click" />
<input id="Hid_Sno" type="hidden" name="hddclick" runat="server" />
</td>
</tr>
</table>
</asp:Panel>
<br />
</asp:Panel>
<ajaxToolkit:ModalPopupExtender ID="MPEClose" runat="server" TargetControlID="Hidden9"
PopupControlID="panClose" CancelControlID="btn2cancel" RepositionMode="RepositionOnWindowResizeAndScroll"
BackgroundCssClass="modalBackground" PopupDragHandleControlID="panClose" />
<asp:Panel ID="panClose" runat="server" CssClass="ModalWindow2" Style="height: 250px;
width: 360px;">
<table>
<tr>
<td style="width: 534px" align="center">
Chick Sales Close
</td>
<td align="right">
<a href="/">
<img src="../images/btn_x.gif" id="btn2cancel" alt="Close" width="56px" height="18px"
border="0" /></a>
</td>
</tr>
</table>
</asp:Panel>
请帮帮我...如何解决这个问题..