i wanted to display the Payment receipt status as pending for radiobuttonlist1 and radiobuttonlist2's selected text after clicking on Add new linkbutton.
i have used the following in rowdatabound event but its not working :
protected void gvDetails_RowDataBound(object sender, GridViewRowEventArgs e)
{
DataRowView drv = e.Row.DataItem as DataRowView;
if (e.Row.RowType == DataControlRowType.DataRow)
{
if ((e.Row.RowState & DataControlRowState.Edit) > 0)
{
RadioButtonList rdott = (RadioButtonList)gvDetails.FooterRow.FindControl("ftrrdottstatus");
RadioButtonList rdoconfirm = (RadioButtonList)gvDetails.FooterRow.FindControl("ftrrdoConfirmation");
if (rdott.SelectedItem.Text == "Received" || rdott.SelectedItem.Text == "Not Received" || rdoconfirm.SelectedItem.Text == "Confirmed" || rdoconfirm.SelectedItem.Text == "Not Confirmed")
{
((Label)gvDetails.FindControl("Label7")).Text = "Payment Receipt Pending";
}
((TextBox)gvDetails.FooterRow.FindControl("txtfpercentage")).Attributes.Add("readonly", "readonly");
((TextBox)gvDetails.FooterRow.FindControl("txtftrdifference")).Attributes.Add("readonly", "readonly");
//((TextBox)gvDetails.Row.FindControl("txtdifference")).Attributes.Add("readonly", "readonly");
RadioButtonList rbtnl = (RadioButtonList)e.Row.FindControl("rdottstatus");
rbtnl.SelectedValue = drv[4].ToString();
RadioButtonList rbtnl1 = (RadioButtonList)e.Row.FindControl("rdoConfirmation");
rbtnl1.SelectedValue = drv[5].ToString();
}
}
}
source:
<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>
Rowcommand:
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.SelectedItem.Text);
command.Parameters.AddWithValue("?confirmationstatus", rdoconfirm.SelectedItem.Text);
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)
{
}
}
}