Solved

datagridcommand brings up a empty row

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

Suggested Solutions

This article will show, step by step, how to integrate R code into a R Sweave document
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?

733 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