Solved

get data in UpdateCommand Datagrid

Posted on 2008-06-15
1
678 Views
Last Modified: 2013-11-07
Hi all,

Here is how i declared my datagrid.
When i click on edit,it is converting the cells to editable textboxes.When i click on update it is raising GridLenders_UpdateCommand

I am trying to get the values changed in my event.But they are comming as empty strings.

I tried with e.items.cells(1).text

Dim txtbox As New TextBox
        txtbox = CType(e.Item.FindControl(e.items.cells(1).text), TextBox)
        MsgBox(txtbox.Text)

But i am getting "" values even there is data .
How to retrive data in this updatecommand  to update my database
<asp:DataGrid ID="gridLenders" runat="server" DataKeyField="id" BorderStyle="Ridge" GridLines="None" BorderWidth="2px" BorderColor="White" BackColor="White" CellPadding= "3" CellSpacing="1" AllowSorting="True" 

			  PagerStyle-HorizontalAlign = "Center" HorizontalAlign="Left" OnEditCommand="gridLenders_EditCommand" OnCancelCommand= "gridLenders_CancelCommand"  OnUpdateCommand="gridLenders_UpdateCommand"

			    OnDeleteCommand= "gridLenders_DeleteCommand" AutoGenerateColumns="false" width="96%" >

 

          

 

        <FooterStyle ForeColor="Black" BackColor="#C6C3C6"></FooterStyle>

 

        <HeaderStyle Font-Bold="True" ForeColor="#FFFFFF" 

 

                  BackColor="#A53A6A"></HeaderStyle>

 

       <FooterStyle BackColor="beige" />

       <Columns>

 

        <asp:BoundColumn DataField="Id" HeaderText="ID"  Visible ="false" >

 

          <ItemStyle BackColor="graytext" />

 

          <HeaderStyle BackColor="graytext" />

 

          </asp:BoundColumn>

 

         

 

          <asp:BoundColumn DataField="Lender" HeaderText="Lender">

 

          <ItemStyle BackColor="GhostWhite" />

 

          </asp:BoundColumn>

 

                  

 

          <asp:BoundColumn DataField="AccreditationId" HeaderText="AccreditationId">

 

          <ItemStyle BackColor="GhostWhite" />

 

          </asp:BoundColumn>

 

        

          <asp:EditCommandColumn CancelText="Cancel" EditText="Edit"  

 

                         UpdateText="Update" HeaderText="Modify">

 

          <ItemStyle BackColor="GhostWhite" />

 

          </asp:EditCommandColumn>

 <asp:ButtonColumn CommandName="Delete" HeaderText="Delete" Text="Delete">

 

          <ItemStyle BackColor="GhostWhite" />

 

          </asp:ButtonColumn>

 </Columns>

 

   </asp:DataGrid>

Open in new window

0
Comment
Question by:lakshmidurga
1 Comment
 
LVL 8

Accepted Solution

by:
theplonk earned 500 total points
ID: 21791074
Try:
Dim txtbox As TextBox = CType(e.Item.Cells(1).Controls(0), TextBox)

http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.datagrid.updatecommand.aspx
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

760 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

20 Experts available now in Live!

Get 1:1 Help Now