Thanks for your reply...

I am using .NET 3.5

In the data source where I populate the gridview, i hard code in a row
at the top of the results and then UNION that into the rest of the
results so I get a blank line at the top of the gridview.... then I
manipulate the EDIT/Delete buttons as seen below....  I am using an
example I found before and tweaked it some but it doesnt work...

Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e
As System.Web.UI.WebControls.GridViewRowEventArgs) Handles
GridView1.RowDataBound
        If e.Row.RowType = DataControlRowType.DataRow Then
            If e.Row.RowIndex = 0 Then
                If e.Row.RowState = DataControlRowState.Normal Then
                    Dim lnkBtn0 As LinkButton =
CType(e.Row.Cells(0).Controls(0), LinkButton)
                    lnkBtn0.Text = "Add"    'Change the text of Edit
LinkButton to "Add"
                    e.Row.Cells(0).Controls.RemoveAt(2) 'Remove the
Delete LinkButton
                    e.Row.Cells(0).Controls.RemoveAt(1) 'Remove the
space LiteralControl between Edit and Delete
                End If
            End If
        End If
    End Sub


Protected Sub GridView1_RowUpdating(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles
GridView1.RowUpdating
        If e.RowIndex = 0 Then
            'Creating a hashtable and store data to it
            Dim hsh As New System.Collections.Hashtable
            For Each x As System.Collections.DictionaryEntry In
e.NewValues
                hsh(x.Key.ToString) = x.Value
            Next
            'Now that we have the data to update our DB in a
hashtable.
            'You just need to write a method to update your database
using the hash table.
            'As in this code, I have a Sub named AddStoreRecord which
takes a hastable as argument and insert a new record to DB.
            SharedStuffs.AddStoreRecord(hsh)
        End If
    End Sub

On Sep 29, 9:24 am, Stephen Russell <[email protected]> wrote:
> On Tue, Sep 28, 2010 at 2:10 PM, crocboy25 <[email protected]> wrote:
> > Hello Group,
>
> > I have tried several times without any success to include in a
> > gridview the ADD feature on the top line to allow users to add a
> > record into the database. I have googled for days and have seen some
> > examples but none that seem to work. Does anyone have any advice or
> > examples of how this works?
>
> ----------------
>
> What version of .NET are you using?
>
> Can you give some code that is not working?  We can help you tweak if
> you share your pain.
>
> --
> Stephen Russell
>
> Sr. Production Systems Programmer
> CIMSgts
>
> 901.246-0159 cell

Reply via email to