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

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

And just how do u do that?

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

>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.

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

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

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

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

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

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
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.