473,320 Members | 1,969 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

How to place data into textboxes from datagrid using editcommandname?

9
Hi all,
Please give me guidance to complete this task.

As per my requirement, I want to place data in to different textboxes whatever I selected from datagrid using edit command name.
Means I need to Binding Database Data into Textboxes whenever I click on the edit button at the end of the each row in datagrid, the data in each cell of the selected row has to be place in different textboxes.
How to solve this issue?

Thanks in Adv.
kolags@hotmail.com
Jan 15 '08 #1
5 2833
dip_developer
648 Expert 512MB
Hi all,
Please give me guidance to complete this task.

As per my requirement, I want to place data in to different textboxes whatever I selected from datagrid using edit command name.
Means I need to Binding Database Data into Textboxes whenever I click on the edit button at the end of the each row in datagrid, the data in each cell of the selected row has to be place in different textboxes.
How to solve this issue?

Thanks in Adv.
kolags@hotmail.com
what is your language?? working platform?? project type???
vb/c#.........????windows/web.....??.net2003/.net2005...???
Jan 16 '08 #2
Kolags
9
In VS-2003 ASP.Net using VB.net.
Jan 16 '08 #3
dip_developer
648 Expert 512MB
In VS-2003 ASP.Net using VB.net.
The DataGrid contains a property called EditItemIndex, which specifies what row of the DataGrid is the
row being edited. The DataGrid numbers its rows starting at 0. By default, the DataGrid is not editing any
row, so the EditItemIndex, by default, has a value of -1. Since we want to mark a row for editing when its "Edit"
button is clicked, we simply need to write some code in the EditCommand event handler, which is the DataGrid
event handler that is fired when the EditCommandColumn control's "Edit" button is clicked. This event handler
simply needs to set the EditItemIndex property to the row whose "Edit" button was clicked and then rebind the
DataGrid data (by calling BindData() or your chosen function name). The code for this event handler can be seen below:

Expand|Select|Wrap|Line Numbers
  1.  
  2. Sub dgProducts_Edit(sender As Object, e As DataGridCommandEventArgs)
  3. dgProducts.EditItemIndex = e.Item.ItemIndex
  4. BindData()
  5. End Sub
  6.  
To wire this event handler up to the EditCommand event, simply specify this in your DataGrid control, like so:

Expand|Select|Wrap|Line Numbers
  1.  
  2. <asp:DataGrid id="dgProducts" runat="server"
  3. ... 
  4. OnEditCommand="dgProducts_Edit"
  5. ... >
  6.  
  7. <Columns>
  8. ...
  9. </Columns> 
  10. </asp:DataGrid>
  11.  
hope it helps...
Jan 16 '08 #4
Kolags
9
Hi,

Thanks alot for your guidence.
Now I have another doubt, I have a check box in my datagrid. As per our requirement, data which is selected by check box should populate in to text boxes. I am able to bind by using edit button, but now I am unable to fire the check box checked event.

It is like general mail system, In our mail inbox we do have a check box, once selected few check boxes we can easily deleting the selected mail by hitting Delete button.
Please suggest how to fire the check box checked event. It's very urgent.
Jan 28 '08 #5
Kolags
9
Hi all,
I have completed my task using the following code for placing data (Data Binding), which is in datagrid. By clicking edit button on the datagrid at the starting column.

Textbox1.text=datagrid.SelectedItem.Cells(1).Text
Then immediately the corresponding data in the datagrid has to populate into textbox.

And the following code can be used for the Second Request (check box type).

Dim DemoGridItem As DataGridItem
For Each DemoGridItem In datagrid.Items
Dim myCheckbox As CheckBox = CType(DemoGridItem.Cells(0).Controls(1), CheckBox)
If myCheckbox.Checked = True Then
rowCount += 1
textbox1.text=",", DemoGridItem.Cells(0).Text

End If
Feb 13 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: sandman | last post by:
I've got a simple windows form with some bound textboxes and Save button. Each texbox is bound to column in a table in an Access database. The form fills fine - all the fields show the correct...
2
by: crocketo | last post by:
Hi, I've made a winform with several labels, textboxes and a datagrid. My question is: How do I, when a row in the datagrid is clicked, retrieve that data? Let's say I've got a datagrid with...
2
by: Josef Meile | last post by:
Hi, I'm using a ComboBox, some Textboxes, and a DataGrid to represent a many-to-many relationship between Person and Course. Each time that I change the value in the ComboBox (which for now is...
0
by: Alex | last post by:
Interested in more .NET stuff visit www.dedicatedsolutions.co.uk The DataList is not as powerful as the DataGrid. It requires more work from you since it has no default data presentation format....
2
by: alpoor | last post by:
I have lots of textboxes on my webform. I need to bind them with fields from table. I am not sure how to bind with textboxes. I have seen so many samples for dropdown boxes and datagrid binding,...
6
by: needin4mation | last post by:
I have a set of textboxes. If it is a new record the textboxes are empty and there is a save button. If this is an existing record, I have a search form, a datagrid and the user selects form the...
1
by: hcs | last post by:
Hello, on a datagrid when you alter the dataset and want to show the new dataset you use datagrid.refresh(). how is this possible on a form which is based on a dataset and consists of a number...
9
by: Anil Gupte | last post by:
After reading a tutorial and fiddling, I finally got this to work. I can now put two tables created with a DataTable class into a DataRelation. Phew! And it works! Dim tblSliceInfo As New...
1
by: geeteshss | last post by:
Dear all, actually i spent a whole month on the R&D of datagrid edit ,update,cancel events but recently my guide told me to make it user friendly because no user would like to go on searching rows...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.