logo
down
shadow

Do subtraction of last two rows of gridview using c#.net


Do subtraction of last two rows of gridview using c#.net

By : SINGLO
Date : November 22 2020, 11:17 AM
should help you out I have a gridview on my page I am binding data from table (Mysql database) to it. Also gridview has AutoGenerateColumns property to 'true'. Now the gridview have all the columns autogenerated and I have last 2 rows named 'Total' & 'HeadCount'. I want to subtract 'HeadCount' from 'Total'. And add new row 'Final Total' to the grid. How can I do this? Should I do it database side? If so How? Should I do it application c# code side? If so How? Please help me out if anyone has an answer for this. ..! , do it as code below
code :
DataColumn totalColumn = new DataColumn();
totalColumn.ColumnName = "FinalTotal";
totalColumn.DataType = typeof (int);
totalColumn.DefaultValue = 0;
dtSourceTable.Columns.Add(totalColumn);

foreach (DataRow row in dtSourceTable.Rows)
{
    row["FinalTotal"] = Convert.ToInt32
       (row["HeadCount"]) - Convert.ToInt32(row["Total"]);
}


Share : facebook icon twitter icon
How to control number of items appearing in GridView rows and columns in a Metro Style GridView App?

How to control number of items appearing in GridView rows and columns in a Metro Style GridView App?


By : Exo Flame
Date : March 29 2020, 07:55 AM
it helps some times You can control it in many ways depending on your layout which you have not shared. If you want a fixed number - make sure the height/width of your GridView is the correct multiple of the number of columns/rows that you want displayed. For example for a default GridView if you want to have 3 rows you could so something like:
code :
<GridView
    Height="700">
    <GridView.ItemContainerStyle>
        <Style
            TargetType="GridViewItem">
            <Setter
                Property="Height"
                Value="200" />
...
How to extract data from a TextBox to a GridView (multiple rows to be displayed in the GridView)?

How to extract data from a TextBox to a GridView (multiple rows to be displayed in the GridView)?


By : Gregor Rohrspatz
Date : March 29 2020, 07:55 AM
it should still fix some issue You have to persists your data between postbacks, you have many options here: by Session, ViewState, Cache and some other.
code :
protected void Page_Load(object sender, EventArgs e)
{
    if (Page.IsPostback)
    {
         dt = Session["data_table"] as DataTable;
    }
}

protected void btnTextDisplay_Click(object sender, EventArgs e)
{
     if (dt == null)
     {
          dt = new DataTable();
          DataColumn dc1 = new DataColumn("Name");
          DataColumn dc2 = new DataColumn("City");
          dt.Columns.Add(dc1);
          dt.Columns.Add(dc2);   
     }

     DataRow dr = dt.NewRow();
     dr[0] = txtName.Text;
     dr[1] = txtCity.Text;
     dt.Rows.Add(dr);
     gvDisplay.DataSource = dt;
     gvDisplay.DataBind();

     Session["data_table"] = dt;
}
How to connect a Button to the Checkboxes in a GridView, and delete the selected rows from the GridView(ticked via Check

How to connect a Button to the Checkboxes in a GridView, and delete the selected rows from the GridView(ticked via Check


By : Françoise Thurre
Date : March 29 2020, 07:55 AM
it should still fix some issue I have created a Gridview containing data extracted from a TextBox. I have a "Delete Link" on the GridView to delete the row from the GridView if required. , Try this..
ASPX Code:
code :
 <asp:TemplateField>
 <ItemTemplate>
 <asp:CheckBox ID="chkdelete" runat="server" />
 </ItemTemplate>
 </asp:TemplateField>
   protected void Button3_Click(object sender, EventArgs e)
{
    foreach (GridViewRow gvrow in GridView1.Rows)
    {
        //Finiding checkbox control in gridview for particular row
        CheckBox chkdelete = (CheckBox)gvrow.FindControl("chkdelete");
        //Condition to check checkbox selected or not
        if (chkdelete.Checked)
        {
            if (Session["reptable"] != null)
            {
                string EmpID = GridView1.DataKeys[gvrow.RowIndex].Value.ToString();
                DataTable dt1 = new DataTable();
                dt1.Clear();
                dt1 = Session["reptable"] as DataTable;
                for (int i = 0; i <= dt1.Rows.Count - 1; i++)
                {
                    DataRow dr;
                    if (dt1.Rows[i][0].ToString() == EmpID)
                    {
                        dr = dt1.Rows[i];
                        dt1.Rows[i].Delete();
                        //dt1.Rows.Remove(dr);
                    }
                }
                //Session.Remove("reptable");
                Session["reptable"] = dt1;
            }

        }
    }
  GridData();
}
delete selected rows from gridview on selecting option from a dropdownlist located outside the gridview

delete selected rows from gridview on selecting option from a dropdownlist located outside the gridview


By : singhalakash
Date : March 29 2020, 07:55 AM
To fix this issue Code On ddlaction_SelectedIndexChanged and stringVariableContainCheckboxvalues is string variable fetch from gridview checkbox selected in format ('1,3,5,6')
code :
if (ddlaction.SelectedValue == "1")
{
  string delref = "delete from tbl_Refferal where ID in (@checkboxSelectedValues)";
  con = new SqlConnection(conString);
  SqlCommand cmd2 = new SqlCommand(delref, con);
  cmd2.Parameters.AddWithValue("@checkboxSelectedValues", stringVariableContainCheckboxvalues);
  con.Open();
  int temp1 = cmd2.ExecuteNonQuery();
  con.Close();
  BindRef();
}
foreach (GridViewRow row in gvRefDetail.Rows)
{
    CheckBox cb = (CheckBox)row.FindControl("CheckBox1");
    if (cb != null && cb.Checked)
    {
       // fetch values in string
    }
}
I need to show the footer template under the rows of gridview to insert/add data into this gridview connected with datab

I need to show the footer template under the rows of gridview to insert/add data into this gridview connected with datab


By : user6025398
Date : March 29 2020, 07:55 AM
Related Posts Related Posts :
  • X509Certificate2.Import with NCRYPT_ALLOW_PLAINTEXT_EXPORT_FLAG
  • Model expands on moving horizontally in unity
  • Custom response when Model binding fails ASP.NET Core API
  • Can you Serialize inside a set of Attributes by Set of Attributes?
  • ASP.NET Web API 2 - Filter POST requests by Query String
  • ValidationAttribute injecting services for unobtrusive client validation
  • UWP - Middle Mouse Wheel Button Click Event Handler
  • .Net Core 2.2 Cookie Authentication Problem
  • How have more than two expands in restier asp.net
  • Autofac Resolve with TypedParameter always pick up first the same type parameter expected?
  • Regluar expression problem. It does not find the needed part of the string
  • How to make a Sum of values in a list for Charts? [ SOLVED ]
  • Nested HttpWebRequest in c#
  • How to read a struct containing array of structs from TwinCat to C#
  • HttpPostedFileBase gets content length to 0 when C# iterates the zipfile
  • xamarin forms HttpClient incomplete Json
  • How can i write more than one string in one line?
  • ASP.NET Core MVC equivalent of Start Action Specific Page
  • Dynamic grid row count and column count with XAML
  • How to query the first entry in each group in NHibernate
  • How can you migrate an entity framework project to .NET standard when the fluent configuration is using HasDatabaseGener
  • Program freezes when using RSA.ImportParameters() on android platform
  • SQL select query - no seconds or milliseconds in datetime
  • ASP.NET Core CORS combining policies; enablecors in controller vs midleware configuration
  • How to stop Firebase Realtime Database Unity SDK listener load all child data at start of application
  • How to offset the Y position of every second column in a Grid Control
  • Client side or server side error on SecurityTokenValidationException certificate expiration
  • if String is empty then data is not inserting
  • How to pass dynamic parameter and inject repository in ActionFilter in asp.net Core 2.2?
  • Select element where attribute contains a certain substring
  • How to get JSON response for column names in database table
  • How can I safely unsubscribe from an Action in one line?
  • How to change icon ( of main Form + another child forms) programatically in c# code while compilation
  • Why is the result of adding two null strings not null?
  • Getting deserialized values
  • What are difference between use invoke and synchronizationcontext.Post object?
  • Asynchronous Communication
  • No connectionString could be found in the test project application config file
  • Building a website that converts address to longitude and latitude and saves in the database
  • WPF Border shape
  • How to Add ItemArray to DataRow at a specific Location in DataTable
  • Try within Linq query
  • How to reduce the execution time?
  • What does T stands for in C#?
  • WPF MVVM Databinding with parameters?
  • How to apply a custom style to a control inside of a custom control template?
  • ASP.NET 4.5 data binding model SelectMethod throw error
  • How does the compiler recognise Nullable<T> to be a 'special type'?
  • Populate DataGridview upon ComboBox selection
  • KeyCommand disabled MenuItem
  • get the data that was returned from the stored procedure SQL Server 2008 silvelight C# Linq
  • Text boxes are not filling when the Form Loads, Windows Form Application
  • multiple input and multiple output in ssis with executing bat file
  • How to replace a string using the original matched value
  • Splitting Date from DateTime
  • How to manage multiple windows in MVVM
  • Setting active a Chrome window (C++)
  • Adding a Custom Task Pane to Word (Without using VSTO)
  • Session is set or not in ASP.NET
  • Not able to pass eval to javascript function
  • shadow
    Privacy Policy - Terms - Contact Us © festivalmusicasacra.org