.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
MarieAdela
Imran Ghani
Post New Web Links

inserting from gridview footer

Posted By:      Posted Date: August 21, 2010    Points: 0   Category :ASP.Net
 

I have been following the tutorials from Scott Mitchell on this site.  I am trying to insert a new record from the gridview footer.  I have my BLL set up as a .cs class in the App Code folder.  When I fill in the fields and click add, nothing happens.  The page refreshes and the text boxes empty, but nothing is added to the database.  The edit and delete functions work fine.  Have I put something in the wrong spot?

 

I have the rowcommand and the datasource_inserting on the code page as below.

protected void Oems_RowCommand(object sender, GridViewCommandEventArgs e)
{
    // Insert data if the CommandName == "Insert" 
    // and the validation controls indicate valid data...
    if (e.CommandName == "Insert" && Page.IsValid)
    {
        // TODO: Insert new record...
        OemsDataSource1.Insert();
    }
}


protected void OemsDataSource1_Inserting
(object sender, ObjectDataSourceMethodEventArgs e)
{
    // Programmatically reference Web controls in the inserting interface...
    TextBox txtOem = (TextBox)GridView1.FooterRow.FindControl("txtOem");
    TextBox txtOemStreet = (TextBox)GridView1.FooterRow.FindControl("txtOemStreet");
    TextBox txtOemCity = (TextBox)GridView1.FooterRow.FindControl("txtOemCity");
    DropDownList


View Complete Post


More Related Resource Links

Inserting new row in GridView in ASP.NET 2.0

  
The GridView was not designed to insert new rows, but there is a way to accomplish this with very little code. This article shows how to do that. The GridView was not designed to insert new rows, but there is a way to accomplish this with very little code.

How to Fixed GridViews Header and Footer when scrolling in asp.net?

  
This article is to show you how to Fix GridView''s Header and Footer in a simple code with CSS and JavaScript

Show grand total running total in GridView Footer

  
In many scenarios we need to display Running total as well as Grand total in GridView footer. In this post i will try to explain in an easy way that how we can display running total & Grand total in a GridView footer combindly. To explain this solution using an example here i use a sales order report. The report contains all sales order amount in a tabular way. I will use a GridView to display sales order amount and use GridView footer to display Running total & Grand total. Let we have a customer table with id and name column plus an orders table with OrderID,CustomerID,OrderDate & Amount. Now our goal is to show all customers order with amount as well as page wise running total & grand total. Note that running total is necessary when you enable paging in a GridView where as Grand total is always you can consider.

sum of 7 column totals in footer of gridview

  
I have implemented column tolals in the footer of my gridview using the technicque described in this article http://aspalliance.com/782 .Now I would like to have a total of the 7 column totals that are displayed in the footer.  Can anyone tell me how to do this.  I would like to display this in a label or an addition row in the footer if that is possible.

Footer and Header in Empty GridView

  
How to make GridView to show Header and Footer when it hasn't got any rows?

Is possible...? set enter key button for gridview footer template..

  
http://geekswithblogs.net/dotNETvinz/archive/2009/06/04/adding-dynamic-rows-in-gridview-with-textboxes.aspxI have used the above grid view in my application . Its working good, no problem. Upon clicking the Addnewrowbutton, it uses to create a new row dynamically. What i need is, new row should also be created dynamically, upon pressing enter key in the last textbox on a particular gird view row.  User always can't go and click addnewrowbutton every time to create new row. Instead of it, user can press enter in the last textbox on a particular grid view row to create new row. Hope you guys have understood. Please Note: Here I have used master page.

Gridview Totals in Footer

  
 I am having problems with displaying the totals in the footer of a gridview. I am writing a page whereby users can enter comments and marks for an online photo competition. The page has a details view to enter the comment and mark. Its has a details view where the photo is displayed. It has a gridview where the comments and marks that have been entered are displayed. It works well - the details view allows comment and mark entry and the gridview show the comments and marks as they are entered. The problems are twofold. Firstly the total shows double the marks that should be displayed. Secondly, when you leave the page and then return later, you have to refresh the page before it will show the latest comment and mark even though it shows this immediately after entering the data. Ive provided my code below:   Partial Class PhotoAlbum_PhotoDetails     Inherits System.Web.UI.Page     Private TotalMarks As Decimal     Protected Sub DisplayComment_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles DisplayComment.RowDataBound         If e.Row.RowType = DataControlRowType.DataRow Then             TotalMarks += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "Mark"))   

Inserting Records Based on Checkbox Selection in a Gridview

  
Using checkboxes, can the row of record(s) be inserted into a database? I am populating a Gridview. Done. A checkbox field has been added, when the user selects one or more rows, a submit button (which is not working) needs to inserting those records into a table. The insert statment will work outside of the page but is not working using the scenario I jut described. Is this task as I have outlined doable? txs Ayomide

Display selected items total in gridview footer

  

Hi all,

           I will have a gridview with checkboxes and some amount fields. I would like to display the sum of the amount in gridview footer depending on the checked items by the user. Can any one give me a sample code


Can not reference text value in footer of Gridview control

  

I have been struggling with this all week end .... Yell

I am trying to implement adding a new record using the Gridview footer.

I have an example that works finethat I got from http://www.aspdotnetcodes.com/GridView_Insert_Edit_Update_Delete.aspx.

My situation is a little different .. as I am using master page and the Gridview is in a page derived from the master page.

I have tried:

Dim txtNewName As TextBox = DirectCast(GridView1.FooterRow.FindControl("NewName"), TextBox)

"NewName" is the ID of the textbox in the footer of the Gridview.

When I try referencing ... txtNewName.Text ... it returns a null value.

There must be some trick to referencing this .Text value when using the Gridview that is within a Content Place Holder that results when using a page that was created using a master page.

 

Thanks in advance fo any possible help with this problem ...

GridView Insert clicking a button in footer row using stored procedure

  

Hi!! I need your help again.

I have a gridview with a button in the first column of the footer row and some controls (textbox, dropdowlist...) in the rest of the columns. I want to click that button and insert into a database table using an stored procedure the text properties of the controls in the other columns.

I don't know what's wrong... could you help me or post me a link to read it??

I'm setting the insert command with my stored procedure, I'm setting the storedprocedure as the insertcommandtype, I'm able to load the controls with correct values, but finally when I click the insert button that's not work!!!!

Thank you!!!


perform sum of textbox values and display the total in gridview footer row textbox

  

i have a gridview in which i have added two textboxes .

the second textbox is placed in footer of gridview

wht i want is when the user enters values in the first textbox the total of these textboxes should be displayed in footer row.

Pls help


Update panel problem in gridview footer

  

On my aspx page, I'm having troubles when I have an update panel within the footer template of a gridview. It appears to be an intermitent problem that occurs on subsequent postback when you do a delete command in the gridview. The first delete command always goes through fine (first postback). Clicking on another row to delete on the gridview (or any other button on the form) triggers this error:

An error has occurred because a control with id 'ctl00$SupremeContent$grdLineNumbers$ctl09$ctl00' could not be located or a different control is assigned to the same ID after postback. If the ID is not assigned, explicitly set the ID property of controls that raise postback events to avoid this error.

If you click the back button in the browser, then click on another page, then come back to this page, you can delete another record. Another attempt to delete another record brings you back to the above problem. Thectl00$SupremeContent$grdLineNumbers$ctl09$ctl00 changes each time you delete, come back to the page and delete.

If I disable the udpate panel, there's no errors.


The reason I have the update panel is so that the user can select the relevant pipe specification (they see multiple columns using a textbox, drop down extender, panel and gridview) without the form's data being reset by the embedded gridview's

Inserting Selected Row onto SQL Server Database from GridView

  




protected void Authorise(object sender, EventArgs e)
        {
            CheckBox chk;

            foreach (GridViewRow rowItem in GridView1.Rows)
            {
               // gets the Debit Reference number for each row checked
                string type = GridView1.DataKeys[rowItem.RowIndex].Values[0].ToString();
				// gets the Debit Error Type Number number for each row checked
                string DDIREF = GridView1.DataKeys[rowItem.RowIndex].Values[1].ToString();
 
                chk = (CheckBox)(rowItem.Cells[0].FindControl("RowChecker"));
   
                // chk.checked will access the checkbox state on button click event
                if (chk.Checked)
                {
                  
					 if (type == "1")
					 {
						// Message_ltr.Text = type + DDIREF;
						 string[] posList;
						 //   string a = "false";
						 DataTable dt = this.ExcelToDatatable_dt;

						 posList = positionList;
						 foreach (DataRow row in dt.Rows)
						 {
								 string error = "No Error Message";
								 fn.InsertNewDDIsTemporary_Proc(
										  row["DDIREF"].ToString()                    //  String DDIREF_P
										, row["Sortcode"].ToString()                  //  String Sortcode_P
										, row["AccountNo"].ToString(

Inserting Selected Row onto SQL Server Database from GridView

  



protected void Authorise(object sender, EventArgs e)
        {
            CheckBox chk;

            foreach (GridViewRow rowItem in GridView1.Rows)
            {
               // gets the Debit Reference number for each row checked
                string type = GridView1.DataKeys[rowItem.RowIndex].Values[0].ToString();
				// gets the Debit Error Type Number number for each row checked
                string DDIREF = GridView1.DataKeys[rowItem.RowIndex].Values[1].ToString();
 
                chk = (CheckBox)(rowItem.Cells[0].FindControl("RowChecker"));
   
                // chk.checked will access the checkbox state on button click event
                if (chk.Checked)
                {
                  
					 if (type == "1")
					 {
						// Message_ltr.Text = type + DDIREF;
						 string[] posList;
						 //   string a = "false";
						 DataTable dt = this.ExcelToDatatable_dt;

						 posList = positionList;
						 foreach (DataRow row in dt.Rows)
						 {
								 string error = "No Error Message";
								 fn.InsertNewDDIsTemporary_Proc(
										  row["DDIREF"].ToString()                    //  String DDIREF_P
										, row["Sortcode"].ToString()                  //  String Sortcode_P
										, row["AccountNo"].ToString()     

How to compare asp.net Textbox value is equal to Gridview footer itemtemplate text box on button cli

  

Hi..

I have one asp.net textbox and gridview footer template textbox on clicking the button, i need to check the textbox value is equal to gridview footer template textbox value are same....


my aspx page code:-

     <asp:TextBox ID="TextBox3" runat="server" TabIndex="1"></asp:TextBox>

<FooterTemplate>
<asp:TextBox id="we" runat="server"  Font-Size="10pt" Font-Names="Palatino Linotype" Font-Bold="True" ForeColor="#000000" Width="106px">
</FooterTemplate>

  <asp:Button ID="Button2" runat="server" BackColor="Transparent" BorderColor="Transparent"                      
                        Font-Size="10pt" ForeColor="#FFFFFF" Height="40px" OnClick="Button2_Click" Style="z-index: 101;
                        left: 113px; background-image: url(images/btn_5.png); position: absolute; top: 13px;
                        background-color: transparent" Text="Save" Width="94px" />





How to Leave footer visible in gridview when datasource is empty

  

HI,


I want to display my <FooterTemplate> or just the textbox and button when the gridview is empty. Here is the code I have that works fine when my datasource is not null but when it is null I want to show the <FooterTemplate> I have. 

Btw my project is VB.Net.  Oh yeah <emptydatatemplate> did not work for me.  I copied the below in between the <emptydatatemplate> and it did not work.  So I removed the template tags inside <emptydatatemplate> and still did not work. Any suggestions?


<asp:GridView ID="mlbGridView" runat="server" AllowPaging="True" AutoGenerateColumns="False" DataKeyNames="ID" DataSourceID="mlbDataSource" ShowFooter="True"  OnRowCommand="mlbGridView_RowCommand">
           
              
        <Columns>
                  <asp:TemplateField>
        

<FooterTemplate>
    <asp:Button ID="btnInsert" runat="se

Categories: 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend