473,503 Members | 479 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Adding extra gridview rows from footer template

1 New Member
Hi
I've been all around looking for an answer to this question, but can't find it.
I've got a gridview with a single unbound column. It's got a textbox and button in the footer row. I"m trying to get the value from the textbox to add to the gridview on the button click. After trying to integrate other solutions into my code I've come up with this garbled mess in the button click event:


DataTable paramValues = new DataTable();
DataColumn ParameterValue = new DataColumn("Value", typeof(string));
paramValues.Columns.Add(ParameterValue);
foreach (GridViewRow row in gdvNewParameterValues.Rows)
{
paramValues.Rows.Add(row.Cells[0].ToString());
}
TextBox value = (TextBox)gdvNewParameterValues.FooterRow.Cells[0].FindControl("txtNewParameterValue");
TableCell tc = new TableCell();
tc.Text = value.Text;
TableRow tr = new TableRow();
tr.Cells.Add(tc);
paramValues.Rows.Add(tr);


gdvNewParameterValues.DataSource = paramValues;
gdvNewParameterValues.DataBind();


Any ideas?
Mar 8 '08 #1
1 3022
dillera1
1 New Member
On the button click event (the button you have in the footer row) do the following...it'll look something like this:

protected void btnSubmitFooterRow_Click(object sender, EventArgs e)
{
Textbox newValue = (Textbox)datatableName.FooterRow.FindControl("txtb xName");
this.sqlDSName.InsertParameters["@valueInSQLDSName"].DefaultValue = newValue.Text;
this.sqlDSName.Insert();
datatableName.Databind();
}

This should help you out some....
Mar 13 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
4855
by: Jim Heavey | last post by:
Trying to figure out the technique which should be used to add rows to a datagrid. I am thinking that I would want an "Add" button on the footer, but I am not quite sure how to do that. Is that...
1
9331
by: Miguel Dias Moura | last post by:
Hello, I have a GridView in my page which is created in runtime. It works fine. My page has 2 Asp Buttons: - The HIDE button makes GridView.Visible = False; - The SHOW button makes...
3
8118
by: Dabbler | last post by:
is there a way to show the header even when GridView is empty? the page looks kind of bare with just empydatatext or emptyrowtemplate. Thanks.
13
41952
by: AG | last post by:
I have a gridview that I bind to a List(of Type) at runtime. Not using a datasource control. The gridview has a template column with an imagebutton whose commandname is set to 'Delete'. The...
8
7706
by: gerry | last post by:
The PagerSettings.Visible property is not being handled properly by the GridView control. The value assigned to this property is not applied until after a postback. Simplest test : .aspx...
2
2093
by: Blasting Cap | last post by:
I've got a gridview (that I converted over from a datagrid, which had been working properly), that is doubling up the number of rows returned. When it was running as a datagrid, the same code sent...
0
2650
by: gnewsgroup | last post by:
Well, I am trying to use the footer row of a GridView for insertion purpose. There are some articles about this, for example, the gridviewguy.com has an example, which always displays the footer...
3
9806
by: tshad | last post by:
I am building a GridView that is displaying some money values in 3 columns. I want to put the totals of each column in a label field (one for each column) in the footer. I was trying to figure...
0
1659
by: Andy B | last post by:
I need to take an existing GridView that connects to a database and gets rows from a table and force it to show x rows in the insert mode. This is what should happen: 1. There is a TextBox in...
0
7203
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7282
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7339
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6995
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
5017
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4678
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3157
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1515
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
738
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.