Solved

datagridcommand brings up a empty row

Posted on 2004-08-08
3
225 Views
Last Modified: 2010-04-17
Hi
I am trying to create a datagrid to update a table. When I click on the edit link/button a grid with a headers is brought up. There are no text boxes to click. I am pasting the code below. Could someone please help.

Private Sub dgLineFill_EditCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dgLineFill.EditCommand
        dgLineFill.EditItemIndex = Int32.Parse(e.Item.ItemIndex)
        dgLineFill.DataBind()
 End Sub
'this is in pageload
 If Not IsPostBack Then

            daLineFill.Fill(dsLineFill1, "lineFill")
            dgLineFill.DataSource = dsLineFill1
            dgLineFill.DataMember = "lineFill"
            dgLineFill.DataBind()
            'dsLineFill1.AcceptChanges()
        End If

<asp:DataGrid id="dgLineFill" runat="server" Height="136px" Width="272px" DataSource="<%# dsLineFill1 %>" DataKeyField="LineFillID" DataMember="LineFill" AutoGenerateColumns="False">
                        <Columns>
                              <asp:BoundColumn DataField="LineFillID" HeaderText="LineFillID"></asp:BoundColumn>
                              <asp:BoundColumn DataField="LineID" HeaderText="LineID"></asp:BoundColumn>
                              <asp:BoundColumn DataField="MonthYear" HeaderText="MonthYear"></asp:BoundColumn>
                              <asp:BoundColumn DataField="LineFillVolume" HeaderText="LineFillVolume"></asp:BoundColumn>
                              <asp:BoundColumn DataField="LocationFormID" HeaderText="LocationFormID"></asp:BoundColumn>
                              <asp:BoundColumn DataField="LocationToID" HeaderText="LocationToID"></asp:BoundColumn>
                              <asp:EditCommandColumn ButtonType="PushButton" UpdateText="Update" CancelText="Cancel" EditText="Edit"></asp:EditCommandColumn>
                        </Columns>
                  </asp:DataGrid>


Thanks in advance for your  help.
0
Comment
Question by:ChanderMadhavi
3 Comments
 
LVL 4

Accepted Solution

by:
rohanpandya earned 300 total points
ID: 11749926
Hi

  fill you datagrid in the page load event try following

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Dim connectionString As String = "Persist Security Info=False;Server=localhost;database=OnlineRecruitment;uid=sa;pwd=sa;"
            objConnection = New SqlConnection(connectionString)
            objCommand = New SqlCommand
            objCommand.CommandText = "Select * from tblUserProfile"
            objCommand.Connection = objConnection
            objDataAdapter = New SqlDataAdapter
            objDataset = New DataSet
            objDataAdapter.SelectCommand = objCommand
            objConnection.Open()
            objDataAdapter.Fill(objDataset, "Test")
            objConnection.Close()
            dgTest.DataSource = objDataset.Tables(0).DefaultView
            dgTest.DataBind()
      End Sub
      Private Sub doEdit(ByVal sender As Object, ByVal e As DataGridCommandEventArgs) Handles dgTest.EditCommand
            dgTest.EditItemIndex = e.Item.ItemIndex
            dgTest.DataBind()
      End Sub
      Private Sub doInsert(ByVal sender As Object, ByVal e As DataGridCommandEventArgs) Handles dgTest.UpdateCommand
            dgTest.SelectedIndex = e.Item.ItemIndex
            Dim txtTest As TextBox = e.Item.Cells(1).Controls(0)
            Dim test As String = txtTest.Text
            Response.Write(txtTest.Text)
      End Sub
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A short article about problems I had with the new location API and permissions in Marshmallow
This is about my first experience with programming Arduino.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

943 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now