I wanted to show the following gridview in my design,so that i can add the payment details but i am not getting the gridview in my design.
i wanted the empty gridview to enter payment details like below link:
<asp:GridView ID="gvDetails" runat="server" AutoGenerateColumns="false" ShowFooter="true" DataKeyNames="Sno" CellPadding="3"
PageSize="2" BackColor="#DEBA84" GridLines="both" BorderColor="#DEBA84" BorderStyle="None" BorderWidth="1px" CellSpacing="2"
Width="720px" OnRowCommand="gvDetails_RowCommand">
<Columns>
<asp:BoundField DataField="Sno" HeaderText="Sno" InsertVisible="False" ReadOnly="True" SortExpression="Sno" />
<asp:TemplateField HeaderText="Amount" SortExpression="Amount">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("Amount") %>'></asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtfamtt" runat="server" Width="100px"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Percentage" SortExpression="Percentage">
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("Percentage") %>'></asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtfpercentage" runat="server" Width="100px"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="TT Status" SortExpression="TT Status">
<EditItemTemplate>
<asp:RadioButtonList ID="rdottstatus" runat="server" Width="100" RepeatDirection="Horizontal">
<asp:ListItem Value="0" Text ="Received"></asp:ListItem>
<asp:ListItem Value="1" Text ="Not Received"></asp:ListItem>
</asp:RadioButtonList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label3" runat="server" Text='<%# Bind("TTStatus") %>'></asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:RadioButtonList ID="ftrrdottstatus" runat="server" Width="100" RepeatDirection="Horizontal">
<asp:ListItem Value="0" Text ="Received"></asp:ListItem>
<asp:ListItem Value="1" Text ="Not Received"></asp:ListItem>
</asp:RadioButtonList>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Confirmation Status" SortExpression="Confirmation Status">
<EditItemTemplate>
<asp:RadioButtonList ID="rdoConfirmation" runat="server" Width="100" RepeatDirection="Horizontal">
<asp:ListItem Value="0" Text ="Confirmed"></asp:ListItem>
<asp:ListItem Value="1" Text ="Not Confirmed"></asp:ListItem>
</asp:RadioButtonList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label4" runat="server" Text='<%# Bind("confirmationstatus") %>'></asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:RadioButtonList ID="ftrrdoConfirmation" runat="server" Width="100" RepeatDirection="Horizontal">
<asp:ListItem Value="0" Text ="Confirmed"></asp:ListItem>
<asp:ListItem Value="1" Text ="Not Confirmed"></asp:ListItem>
</asp:RadioButtonList>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Confirmation Amount" SortExpression="Confirmation Amount">
<EditItemTemplate>
<asp:TextBox ID="txtconfirm" Width="100px" runat="server" Text='<%# Bind("Confirmation") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label5" runat="server" Text='<%# Bind("Confirmation") %>'></asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtftrconfirm" Width="100px" runat="server" Text='<%# Bind("confirmationamount") %>'></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Difference Amount" SortExpression="Difference Amount">
<EditItemTemplate>
<asp:TextBox ID="txtdifference" Width="100px" runat="server" Text='<%# Bind("Difference") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label6" runat="server" Text='<%# Bind("Difference") %>'></asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtftrdifference" Width="100px" runat="server" Text='<%# Bind("Differenceamount") %>'></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Payment Receipt Status" SortExpression="Payment Receipt Status">
<ItemTemplate>
<asp:Label ID="Label7" runat="server" Text='<%# Bind("Paymentstatus") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<EditItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True" CommandName="Update" Text="Update"></asp:LinkButton>
<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel"></asp:LinkButton>
</EditItemTemplate>
<FooterTemplate>
<asp:LinkButton ID="LinkButton3" runat="server" CausesValidation="False" CommandName="AddNew" Text="Add New"></asp:LinkButton>
</FooterTemplate>
<ItemTemplate>
<asp:LinkButton ID="LinkButton4" runat="server" CausesValidation="False" CommandName="Edit" Text="Edit"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:CommandField HeaderText="Delete" ShowDeleteButton="True" ShowHeader="false" />
</Columns>
</asp:GridView>
code behind:
private void FillVendorGrid()
{
Int64 currInvoiceId = Convert.ToInt64(Request.QueryString["edit_invoice_id"]);
MySqlConnection connect = null;
try
{
string connectStr = ConfigurationManager.ConnectionStrings["ExpoCrmConnectionString"].ToString();
connect = new MySqlConnection(connectStr);
string queryStr = "select * from payment_receipt_status where invoic_id=?iid";
connect.Open();
MySqlCommand command = new MySqlCommand(queryStr, connect);
command.Parameters.AddWithValue("?iid", currInvoiceId);
MySqlDataReader reader = command.ExecuteReader(CommandBehavior.CloseConnection);
DataTable dt = new DataTable();
dt.Load(reader);
// command.ExecuteNonQuery();
if (dt.Rows.Count > 0)
{
gvDetails.DataSource = dt;
gvDetails.DataBind();
}
connect.Close();
}
catch
{
connect.Close();
}
}
protected void gvDetails_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName.Equals("AddNew"))
{
TextBox txtam = (TextBox)gvDetails.FooterRow.FindControl("txtfamtt");
TextBox txtper = (TextBox)gvDetails.FooterRow.FindControl("txtfpercentage");
TextBox txtconf = (TextBox)gvDetails.FooterRow.FindControl("txtftrconfirm");
TextBox txtdiff = (TextBox)gvDetails.FooterRow.FindControl("txtftrdifference");
RadioButtonList rdott = (RadioButtonList)gvDetails.FooterRow.FindControl("ftrrdottstatus");
RadioButtonList rdoconfirm = (RadioButtonList)gvDetails.FooterRow.FindControl("ftrrdoConfirmation");
Int64 currInvoiceId = Convert.ToInt64(Request.QueryString["edit_invoice_id"]);
try
{
MySqlConnection connect;
string connectStr = ConfigurationManager.ConnectionStrings["ExpoCrmConnectionString"].ToString();
connect = new MySqlConnection(connectStr);
string queryStr = "insert into payment_receipt_status(invoic_id,Amount,Percentage,TTStatus,confirmationstatus,confirmationamount,Differenceamount)values(?iid,?Amount,?Percentage,?TTStatus,?confirmationstatus,?confirmationamount,?Differenceamount)";
connect.Open();
MySqlCommand command = new MySqlCommand(queryStr, connect);
command.Parameters.AddWithValue("?iid", currInvoiceId);
command.Parameters.AddWithValue("?Amount", txtam.Text);
command.Parameters.AddWithValue("?Percentage", txtper.Text);
command.Parameters.AddWithValue("?TTStatus", rdott.SelectedValue);
command.Parameters.AddWithValue("?confirmationstatus", rdoconfirm.SelectedValue);
command.Parameters.AddWithValue("?confirmationamount", txtconf.Text);
command.Parameters.AddWithValue("?Differenceamount", txtdiff.Text);
command.ExecuteNonQuery();
connect.Close();
FillVendorGrid();
txtam.Text = "";
txtper.Text = "";
txtconf.Text = "";
txtdiff.Text = "";
connect.Close();
}
catch(Exception ex)
{
}
}
}
}
Any help will be highly appreciated.