954,580 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Select Datagrid row

Hey Guys

I need to be able to select or hightlight datagrid row when a user place a mouse on certain record then, he/she can be able to click delete or edit button to delete the selected row or edit the selected row, can anyone tell me how to do that coz I cant select rows on my datagrid, in there anycode or property I need to set

Thanks in advance

Traicey
Posting Whiz in Training
283 posts since Mar 2008
Reputation Points: 26
Solved Threads: 19
 

use 2 forms in any 2 cells and use Delete query.

furqan219
Junior Poster in Training
89 posts since Jun 2009
Reputation Points: 2
Solved Threads: 4
 

And just how do u do that?

Traicey
Posting Whiz in Training
283 posts since Mar 2008
Reputation Points: 26
Solved Threads: 19
 

why dont you add check boxes in the datagrid? for the rows whose checkboxes are checked, highlight the row

carobee
Posting Whiz in Training
209 posts since Dec 2007
Reputation Points: 10
Solved Threads: 12
 

>I cant select rows on my datagrid..
Your data source might be empty or you disabled the datagrid or you haven't place select button.

Which version of .net framework are you using? If you code then show us.

__avd
Posting Genius (adatapost)
Moderator
8,648 posts since Oct 2008
Reputation Points: 2,136
Solved Threads: 1,241
 

Its VS 2008, what I am doing is I am binding a table from Oracle to a datagrid and I wana be able to select/highlight a row from a datagrid and transfer the data from the selected row to another form where I can be able to edit the record and save and it is updated to the database again

for example on my datagrid, I have Name, Surname, DOB, City, etc and then I have a editwebform that is editing those attributes, in this editwebform I have NameTextbox, surnameTextbox, etc and I want to select the row on the datagrid and click edit button and edit button should open my editwebform with the data of the selected record then I can edit the record and save it and bind the datagrid again, I hope thats clear

Traicey
Posting Whiz in Training
283 posts since Mar 2008
Reputation Points: 26
Solved Threads: 19
 

Great! but where is your problem? I think you are unable to code. Isn't it?

__avd
Posting Genius (adatapost)
Moderator
8,648 posts since Oct 2008
Reputation Points: 2,136
Solved Threads: 1,241
 

Yah ur right why I didnt think about that, I actually am, but I can write a code to edit and get the data from database what Im struggling to do is to make sure that the row is selected from the datagrid and only the values from the datagrid are brought foward to the edit form

Traicey
Posting Whiz in Training
283 posts since Mar 2008
Reputation Points: 26
Solved Threads: 19
 

If you zip your code and upload it to this thread so I can help you.

__avd
Posting Genius (adatapost)
Moderator
8,648 posts since Oct 2008
Reputation Points: 2,136
Solved Threads: 1,241
 

Well my code is in my laptop at home and at work w r using sql server whereas I used oracle for my project, coz I know in SQL is much easier than it is in Oracle, i could do it in SQL but in Oracle its quite a mission n the only reason I used oracle for my project is bcoz it was the only software I cud get hold of without any complications

What Im thinking is Im gona have a selectbutton on my DataGrid and then have a selectbuttoncommand which is gona be uploading the selected record on my edit form, but my problem is, I havent tried it, is it possible for a editcommandbutton in datagrid, or selectcommandbutton to open another form, I think it it but I will get back to u if I have trouble doing that

Thanks hey

Traicey
Posting Whiz in Training
283 posts since Mar 2008
Reputation Points: 26
Solved Threads: 19
 
dnanetwork
Practically a Master Poster
Banned
633 posts since May 2008
Reputation Points: 28
Solved Threads: 106
 

Hi

You can place an edit button or link button in grid.
Pass data of the row to your edit page on click of the button.

Read the row data in properties of object and transfer those to Edit page using

HttpContext.Current.Items.Add("CTX_O", objServiceCharges);

Get these on your Edit Page in viewState

if (ViewState["CTX_O"] != null)
                {                  
             Get the values from viewstate into your controls
}
nicky.23in
Newbie Poster
6 posts since Jun 2009
Reputation Points: 10
Solved Threads: 1
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You