<asp:GridView ID="gvModification" runat="server" EmptyDataText="No Record" AutoGenerateColumns="False"
DataKeyNames="id" OnRowCancelingEdit="gvModification_RowCancelingEdit" OnRowCommand="gvModification_RowCommand"
OnRowDataBound="gvModification_RowDataBound" OnRowDeleting="gvModification_RowDeleting"
OnRowEditing="gvModification_RowEditing" OnRowUpdating="gvModification_RowUpdating"
Style="font-family: Arial, Helvetica, sans-serif; font-size: small" Width="100%"
CellPadding="4" ForeColor="#333333" GridLines="None">
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<Columns>
<asp:TemplateField HeaderText="Date">
<ItemTemplate>
<asp:Label ID="lblDate" runat="server" Text='<%# Eval("DATE")%>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtDate" Width="150" runat="server" Text='<%# Eval("DATE") %>'></asp:TextBox>
<cc1:CalendarExtender ID="CalendarExtender1" Format="dd/MM/yyyy" runat="server" TargetControlID="txtDate">
</cc1:CalendarExtender>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="ITEM">
<ItemTemplate>
<asp:Label ID="lblItem" runat="server" Text='<%# Eval("ItemName") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList ID="ddlItem" runat="server" DataSourceID="SqlDataSource1" SelectedValue='<%# Bind("ITEMCODE") %>'
DataTextField="ITEMNAME" DataValueField="ITEMCODE">
</asp:DropDownList>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:HiddenField ID="hnfItemCode" runat="server" Value='<%#Eval("Itemcode") %>' Visible="false" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Quantity" HeaderStyle-HorizontalAlign="Right" ItemStyle-HorizontalAlign="Right">
<ItemTemplate>
<asp:Label ID="lblQty" runat="server" Text='<%# Eval("Qty") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtQty" Width="50" runat="server" Text='<%# Eval("Qty") %>'></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:HiddenField ID="hnChallan" runat="server" Value='<%# Eval("mvoucher") %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="lbEdit" runat="server" CommandName="Edit" Text="Edit">
</asp:LinkButton>
<asp:LinkButton ID="lbDelete" runat="server" CommandArgument='<%#Bind("ID") %>' CommandName="Delete"
Text="Delete"></asp:LinkButton>
</ItemTemplate>
<EditItemTemplate>
<asp:LinkButton ID="lbUpdate" runat="server" CommandName="Update" Text="Update"></asp:LinkButton>
<asp:LinkButton ID="lbCancel" runat="server" CommandName="Cancel" Text="Cancel"></asp:LinkButton>
</EditItemTemplate>
</asp:TemplateField>
</Columns>
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" CssClass="grd" />
<EditRowStyle BackColor="#999999" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
</asp:GridView>
c#
protected void gvModification_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Delete")
{
int id = Convert.ToInt32(e.CommandArgument);
objrequest.id = id.ToString();
objrequest.delrecord1();
Page.ClientScript.RegisterStartupScript(typeof(Page), "Deleted", "alert('Deleted ')", true);
modification();
try
{
if (gvModification.Rows.Count <= 0)
{
objrequest.updatehead();
DataSet ds = RealStateClass.Requestpage.getrerqestion(txtrequestNo.Text.ToString());
if (ds.Tables[0].Rows.Count > 0)
{ }
else
{
objrequest.CINVNO = txtrequestNo.Text.ToString();
objrequest.delrecord2();
}
}
}
catch (Exception) { }
finally { }
}
}
protected void gvModification_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
}
protected void gvModification_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
string st1 = ((TextBox)gvModification.Rows[e.RowIndex].Cells[0].FindControl("txtDate")).Text;
string st2 = ((DropDownList)gvModification.Rows[e.RowIndex].Cells[2].FindControl("ddlItem")).SelectedItem.Value;
string st3 = ((TextBox)gvModification.Rows[e.RowIndex].Cells[1].FindControl("txtQty")).Text;
string st4 = ((HiddenField)gvModification.Rows[e.RowIndex].Cells[3].FindControl("hnChallan")).Value;
DateTime dt2;
dt2 = Convert.ToDateTime(st1, System.Globalization.CultureInfo.CreateSpecificCulture("en-CA"));
objrequest.Date = dt2;
objrequest.ItemCode = st2.ToString();
objrequest.Quantity = st3.ToString();
objrequest.id = gvModification.DataKeys[e.RowIndex].Values["id"].ToString();
objrequest.updaterequestmodi();
gvModification.EditIndex = -1;
modification();
}
protected void gvModification_RowDataBound(object sender, GridViewRowEventArgs e)
{
}
protected void gvModification_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
gvModification.EditIndex = -1;
modification();
}
protected void gvModification_RowEditing(object sender, GridViewEditEventArgs e)
{
gvModification.EditIndex = e.NewEditIndex;
modification();
}
DataKeyNames="id" OnRowCancelingEdit="gvModification_RowCancelingEdit" OnRowCommand="gvModification_RowCommand"
OnRowDataBound="gvModification_RowDataBound" OnRowDeleting="gvModification_RowDeleting"
OnRowEditing="gvModification_RowEditing" OnRowUpdating="gvModification_RowUpdating"
Style="font-family: Arial, Helvetica, sans-serif; font-size: small" Width="100%"
CellPadding="4" ForeColor="#333333" GridLines="None">
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<Columns>
<asp:TemplateField HeaderText="Date">
<ItemTemplate>
<asp:Label ID="lblDate" runat="server" Text='<%# Eval("DATE")%>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtDate" Width="150" runat="server" Text='<%# Eval("DATE") %>'></asp:TextBox>
<cc1:CalendarExtender ID="CalendarExtender1" Format="dd/MM/yyyy" runat="server" TargetControlID="txtDate">
</cc1:CalendarExtender>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="ITEM">
<ItemTemplate>
<asp:Label ID="lblItem" runat="server" Text='<%# Eval("ItemName") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList ID="ddlItem" runat="server" DataSourceID="SqlDataSource1" SelectedValue='<%# Bind("ITEMCODE") %>'
DataTextField="ITEMNAME" DataValueField="ITEMCODE">
</asp:DropDownList>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:HiddenField ID="hnfItemCode" runat="server" Value='<%#Eval("Itemcode") %>' Visible="false" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Quantity" HeaderStyle-HorizontalAlign="Right" ItemStyle-HorizontalAlign="Right">
<ItemTemplate>
<asp:Label ID="lblQty" runat="server" Text='<%# Eval("Qty") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtQty" Width="50" runat="server" Text='<%# Eval("Qty") %>'></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:HiddenField ID="hnChallan" runat="server" Value='<%# Eval("mvoucher") %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="lbEdit" runat="server" CommandName="Edit" Text="Edit">
</asp:LinkButton>
<asp:LinkButton ID="lbDelete" runat="server" CommandArgument='<%#Bind("ID") %>' CommandName="Delete"
Text="Delete"></asp:LinkButton>
</ItemTemplate>
<EditItemTemplate>
<asp:LinkButton ID="lbUpdate" runat="server" CommandName="Update" Text="Update"></asp:LinkButton>
<asp:LinkButton ID="lbCancel" runat="server" CommandName="Cancel" Text="Cancel"></asp:LinkButton>
</EditItemTemplate>
</asp:TemplateField>
</Columns>
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" CssClass="grd" />
<EditRowStyle BackColor="#999999" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
</asp:GridView>
c#
protected void gvModification_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Delete")
{
int id = Convert.ToInt32(e.CommandArgument);
objrequest.id = id.ToString();
objrequest.delrecord1();
Page.ClientScript.RegisterStartupScript(typeof(Page), "Deleted", "alert('Deleted ')", true);
modification();
try
{
if (gvModification.Rows.Count <= 0)
{
objrequest.updatehead();
DataSet ds = RealStateClass.Requestpage.getrerqestion(txtrequestNo.Text.ToString());
if (ds.Tables[0].Rows.Count > 0)
{ }
else
{
objrequest.CINVNO = txtrequestNo.Text.ToString();
objrequest.delrecord2();
}
}
}
catch (Exception) { }
finally { }
}
}
protected void gvModification_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
}
protected void gvModification_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
string st1 = ((TextBox)gvModification.Rows[e.RowIndex].Cells[0].FindControl("txtDate")).Text;
string st2 = ((DropDownList)gvModification.Rows[e.RowIndex].Cells[2].FindControl("ddlItem")).SelectedItem.Value;
string st3 = ((TextBox)gvModification.Rows[e.RowIndex].Cells[1].FindControl("txtQty")).Text;
string st4 = ((HiddenField)gvModification.Rows[e.RowIndex].Cells[3].FindControl("hnChallan")).Value;
DateTime dt2;
dt2 = Convert.ToDateTime(st1, System.Globalization.CultureInfo.CreateSpecificCulture("en-CA"));
objrequest.Date = dt2;
objrequest.ItemCode = st2.ToString();
objrequest.Quantity = st3.ToString();
objrequest.id = gvModification.DataKeys[e.RowIndex].Values["id"].ToString();
objrequest.updaterequestmodi();
gvModification.EditIndex = -1;
modification();
}
protected void gvModification_RowDataBound(object sender, GridViewRowEventArgs e)
{
}
protected void gvModification_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
gvModification.EditIndex = -1;
modification();
}
protected void gvModification_RowEditing(object sender, GridViewEditEventArgs e)
{
gvModification.EditIndex = e.NewEditIndex;
modification();
}
No comments:
Post a Comment