Discover the primary key values in a gridview while editing it

A

Andrea

The Gridview's RowDeleting event, give the power - cycling the e.Keys Dictionary,
to discover
the values of the Primary key fields of the dataset setup throught the DataKeyNames.

Since I want to get the same value to display a more detailied form to edit
my gridview fields
that cannot be contained in a gridview, How can I do that?

Any link, sample etc?

Thanks.
Andre
 
J

Jan Hyde

Andrea <googlegroups@fuck_the_spam_cleanmail.it>'s wild
thoughts were released on Wed, 7 Jun 2006 22:08:15 +0000
(UTC) bearing the following fruit:
The Gridview's RowDeleting event, give the power - cycling the e.Keys Dictionary,
to discover
the values of the Primary key fields of the dataset setup throught the DataKeyNames.

Since I want to get the same value to display a more detailied form to edit
my gridview fields
that cannot be contained in a gridview, How can I do that?

Any link, sample etc?

I'm afraid I don't understand the question, could you
rephrase it?


Jan Hyde (VB MVP)
 
A

Andrea

I'm afraid I don't understand the question, could you rephrase it?

I think a sample could let anyone understand.

protected void GridViewMain_RowDeleting(object sender, GridViewDeleteEventArgs
e)
{
foreach (DictionaryEntry de in e.Keys)
{
....
}
}

Ok ... with code above, asking for de.Values, I'm able to get the values
of the PrimaryKeys
of the bounded dataSet.

What I need is to get the same values also in RowEditing events, but the
event structure
is different and I've not direct access to that data.

I tried then to add two hidden columns where report the values that I need,
as showed
in the MSDN sample, with the code below I should be able to get the value
of a X column

void CustomersGridView_RowEditing(Object sender, GridViewEditEventArgs e)
{

// Get the country for the row being edited. For this example, the
// country is contained in the seventh column (index 6).
String country = CustomersGridView.Rows[e.NewEditIndex].Cells[6].Text;

.....

I don't changed the code, it's exactly like MSDN display, but in my code,
simple changing
the control name and the cell where the data is stored, I got an empty text
for all cells.

So I don't know how to get my value and continue the editing.
I want, after intercepted the value of the row is being edited, to display
a different edit
form and not let user edit that value inside the gridview.

If you have some sample or link I can read, I'll appreciate it.

Thank
Andrea
 
A

Andrea

Well that's the reply

GridViewMain.DataKeys[e.NewEditIndex].Values[X]

Thanks
Andre
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top