Solved

get data in UpdateCommand Datagrid

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
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…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.

920 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

12 Experts available now in Live!

Get 1:1 Help Now