Solved

get data in UpdateCommand Datagrid

Posted on 2008-06-15
1
687 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

828 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