Adding extra gridview rows from footer template

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bJames
    New Member
    • Mar 2008
    • 1

    Adding extra gridview rows from footer template

    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("Val ue", typeof(string)) ;
    paramValues.Col umns.Add(Parame terValue);
    foreach (GridViewRow row in gdvNewParameter Values.Rows)
    {
    paramValues.Row s.Add(row.Cells[0].ToString());
    }
    TextBox value = (TextBox)gdvNew ParameterValues .FooterRow.Cell s[0].FindControl("t xtNewParameterV alue");
    TableCell tc = new TableCell();
    tc.Text = value.Text;
    TableRow tr = new TableRow();
    tr.Cells.Add(tc );
    paramValues.Row s.Add(tr);


    gdvNewParameter Values.DataSour ce = paramValues;
    gdvNewParameter Values.DataBind ();


    Any ideas?
  • dillera1
    New Member
    • Mar 2008
    • 1

    #2
    On the button click event (the button you have in the footer row) do the following...it' ll look something like this:

    protected void btnSubmitFooter Row_Click(objec t sender, EventArgs e)
    {
    Textbox newValue = (Textbox)datata bleName.FooterR ow.FindControl( "txtbxName" );
    this.sqlDSName. InsertParameter s["@valueInSQLDSN ame"].DefaultValue = newValue.Text;
    this.sqlDSName. Insert();
    datatableName.D atabind();
    }

    This should help you out some....

    Comment

    Working...