Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

get data in UpdateCommand Datagrid

Posted on 2008-06-15
1
Medium Priority
?
693 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
[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
1 Comment
 
LVL 8

Accepted Solution

by:
theplonk earned 1500 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.
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…

618 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