Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > How to read input from a textfield in a datagrid !?!

Reply
Thread Tools

How to read input from a textfield in a datagrid !?!

 
 
Remco Groot Beumer
Guest
Posts: n/a
 
      11-06-2003
Hello,

I'm working with a datagrid control in ASP.NET. The datagrid shows a list of
products. One column shows the productnumber, one column shows the
productname, one column shows a picture of the product and the last column
shows an empty textbox with an 'OK' button.

People can enter a quantity in the empty textbox. After clicking on the 'OK'
button, the product and quantity should be added to another datagrid. The
problem is that I don't know how to read the quantity. I now do this as
follows (cells(5) is the template-column with the textbox, the 'OK' button
triggers the SelectedIndexChanged event):

Private Sub grdArtikelen_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles grdArtikelen.SelectedIndexChanged

Dim txb As TextBox
=CType(Me.grdProducts.SelectedItem.Cells(5).Contro ls(1), TextBox)

Dim dblQuantity As Double

dblQuantity = CType(txb.Text, Double)

End Sub



This code gets the right textbox, but the TEXT property is always empty. How
can I get the text that has been entered in the textbox?

Any help would be appreciated.

Greetings,

Remco


 
Reply With Quote
 
 
 
 
SSW
Guest
Posts: n/a
 
      11-10-2003
Hi,

To trap the even form BtnOk in Datagid, U need to trap Datagid Event Name "ItemCommand".
Follow the step as below.

1) Give BtnOk CommandName let's say grdArtikelen_ BtnOk
2) Attach a Event ItemCommand to Datagrid(Event name will be grdArtikelen_ItemCommand)
3) Check e.CommandName if it is grdArtikelen_ BtnOk then procide with ur Process.

Below is the same code in C#.
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Sample Code Event tape for Datagrid grdArtikelen ItemCommand
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
private void grdArtikelen_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
if(e.CommandName=="grdArtikelen_ BtnOk")
{
Response.Write("Yes U Got It ");
Response.Write(((TextBox)(grdArtikelen.Items[e.Item.ItemIndex].Cells[0].FindControl("txtQty"))).Text); // To Read TextBox Value.
// Place ur code here to Process on BtnOk Click
}
}

Hope this helps.

Thanks,

sswalia
MCSD, MCAD, OCA

"Remco Groot Beumer" <> wrote in message news:bodr3p$75f$...
> Hello,
>
> I'm working with a datagrid control in ASP.NET. The datagrid shows a list of
> products. One column shows the productnumber, one column shows the
> productname, one column shows a picture of the product and the last column
> shows an empty textbox with an 'OK' button.
>
> People can enter a quantity in the empty textbox. After clicking on the 'OK'
> button, the product and quantity should be added to another datagrid. The
> problem is that I don't know how to read the quantity. I now do this as
> follows (cells(5) is the template-column with the textbox, the 'OK' button
> triggers the SelectedIndexChanged event):
>
> Private Sub grdArtikelen_SelectedIndexChanged(ByVal sender As System.Object,
> ByVal e As System.EventArgs) Handles grdArtikelen.SelectedIndexChanged
>
> Dim txb As TextBox
> =CType(Me.grdProducts.SelectedItem.Cells(5).Contro ls(1), TextBox)
>
> Dim dblQuantity As Double
>
> dblQuantity = CType(txb.Text, Double)
>
> End Sub
>
>
>
> This code gets the right textbox, but the TEXT property is always empty. How
> can I get the text that has been entered in the textbox?
>
> Any help would be appreciated.
>
> Greetings,
>
> Remco
>
>


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Output VALUE of INPUT textfield using document.write Stumped and Confused Javascript 13 09-23-2004 02:50 AM
How to read input from a textfield in a datagrid !?! Remco Groot Beumer ASP .Net Web Services 2 11-10-2003 05:40 AM
How to read input from a textfield in a datagrid !?! Remco Groot Beumer ASP .Net Building Controls 1 11-10-2003 05:40 AM
How to read input from a textfield in a datagrid !?! Remco Groot Beumer ASP .Net 0 11-06-2003 04:02 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57