PC Review Forums Newsgroups Microsoft DotNet Microsoft ADO .NET Datagrid Problems

Reply

Datagrid Problems

 
Thread Tools Rate Thread
Old 18-09-2006, 07:52 AM   #1
Calson33
Guest
 
Posts: n/a
Default Datagrid Problems


I created a datagrid with an edit button which redirects to another
page for editing. This seemed to work fine. Then, I added a way to
search which just modified the SQL by adding a WHERE clause (I know,
it's going to be put into a stored proc, just trying to get it to work
for now).
This also seemed to work... Until I clicked on the edit button. It
brings up the wrong record.
I tried
mygrid.DataKeys[e.Item.ItemIndex].ToString()
and then I put the primary key into a column, and tried
e.Item.Cells[0].Text
which also brings up the wrong primary key. The really wierd thing is
that the correct primary key is displayed in the column.

Can anyone help me?

  Reply With Quote
Old 22-09-2006, 02:43 PM   #2
Francois Bonin [C# MVP]
Guest
 
Posts: n/a
Default Re: Datagrid Problems

Is it ASP.NET you are talking about (your redirection statement seems to
indicate that)?
If it is, what event are you using the e.Item.ItemIndex in (i.e. what is
the type of the parameter e)?


"Calson33" <Calson33@gmail.com> wrote in message
news:1158562352.940975.119100@i3g2000cwc.googlegroups.com...
>I created a datagrid with an edit button which redirects to another
> page for editing. This seemed to work fine. Then, I added a way to
> search which just modified the SQL by adding a WHERE clause (I know,
> it's going to be put into a stored proc, just trying to get it to work
> for now).
> This also seemed to work... Until I clicked on the edit button. It
> brings up the wrong record.
> I tried
> mygrid.DataKeys[e.Item.ItemIndex].ToString()
> and then I put the primary key into a column, and tried
> e.Item.Cells[0].Text
> which also brings up the wrong primary key. The really wierd thing is
> that the correct primary key is displayed in the column.
>
> Can anyone help me?
>



  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off