Solved

datagridcommand brings up a empty row

Posted on 2004-08-08
3
217 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
count7 challenge 12 69
changePi Challenge 15 75
eclipse package explorer vs project explorer view 2 28
Base1 Encode/Decode 3 29
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
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 …

708 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

21 Experts available now in Live!

Get 1:1 Help Now