Solved

datagridcommand brings up a empty row

Posted on 2004-08-08
3
254 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
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 …

717 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