473,507 Members | 2,504 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Set the selectedindex of a datagrid

Hi there.
I have a customer's address grid in my web application.
After I searched for a customer I showded all his addresses.
One of these addresses is the ship address.
In the search, I gotten the addressId of this ship address.
The datakey of datagrid is the AddressID.
I want to keep selected the grid row of this address.

How can I do that?

tks.

Fernando
Nov 19 '05 #1
7 1147
myDataGrid.SelectedIndex = myIndex;

Regards,
Kostadin Kostov

"Fernando Lopes" wrote:
Hi there.
I have a customer's address grid in my web application.
After I searched for a customer I showded all his addresses.
One of these addresses is the ship address.
In the search, I gotten the addressId of this ship address.
The datakey of datagrid is the AddressID.
I want to keep selected the grid row of this address.

How can I do that?

tks.

Fernando

Nov 19 '05 #2
Ok Kostadin.
But, I have the AddressID, not the index of the datagrid.

index addressid street
1 1001 aaaaaaaaa
2 736 bbbbbbbbbb

Understand?

tks.

Fernando

"Kostadin Kostov" <Ko************@discussions.microsoft.com> wrote in
message news:44**********************************@microsof t.com...
myDataGrid.SelectedIndex = myIndex;

Regards,
Kostadin Kostov

"Fernando Lopes" wrote:
Hi there.
I have a customer's address grid in my web application.
After I searched for a customer I showded all his addresses.
One of these addresses is the ship address.
In the search, I gotten the addressId of this ship address.
The datakey of datagrid is the AddressID.
I want to keep selected the grid row of this address.

How can I do that?

tks.

Fernando

Nov 19 '05 #3
Have you tried this?

index = DataGrid1.SelectedIndex
key = DataGrid1.DataKeys(index)

Sandy

"Fernando Lopes" wrote:
Ok Kostadin.
But, I have the AddressID, not the index of the datagrid.

index addressid street
1 1001 aaaaaaaaa
2 736 bbbbbbbbbb

Understand?

tks.

Fernando

"Kostadin Kostov" <Ko************@discussions.microsoft.com> wrote in
message news:44**********************************@microsof t.com...
myDataGrid.SelectedIndex = myIndex;

Regards,
Kostadin Kostov

"Fernando Lopes" wrote:
Hi there.
I have a customer's address grid in my web application.
After I searched for a customer I showded all his addresses.
One of these addresses is the ship address.
In the search, I gotten the addressId of this ship address.
The datakey of datagrid is the AddressID.
I want to keep selected the grid row of this address.

How can I do that?

tks.

Fernando


Nov 19 '05 #4
Tks Sandy, the proble is
I don't have de index. I wrote just to watch the differences betweeen the
index and de addressID.

So, I just have the addressID (int) and the grid like:
addressid street
1001 aaaaaaaaa
736 bbbbbbbbbb

Tks again

Fernando

"Sandy" <Sa***@discussions.microsoft.com> wrote in message
news:E5**********************************@microsof t.com...
Have you tried this?

index = DataGrid1.SelectedIndex
key = DataGrid1.DataKeys(index)

Sandy

"Fernando Lopes" wrote:
Ok Kostadin.
But, I have the AddressID, not the index of the datagrid.

index addressid street
1 1001 aaaaaaaaa
2 736 bbbbbbbbbb

Understand?

tks.

Fernando

"Kostadin Kostov" <Ko************@discussions.microsoft.com> wrote in
message news:44**********************************@microsof t.com...
myDataGrid.SelectedIndex = myIndex;

Regards,
Kostadin Kostov

"Fernando Lopes" wrote:

> Hi there.
> I have a customer's address grid in my web application.
> After I searched for a customer I showded all his addresses.
> One of these addresses is the ship address.
> In the search, I gotten the addressId of this ship address.
> The datakey of datagrid is the AddressID.
> I want to keep selected the grid row of this address.
>
> How can I do that?
>
> tks.
>
> Fernando
>
>
>


Nov 19 '05 #5
If the AddressID is in the DataGridKeys collection (meaning it was in there
because you set "AddressID" as the DataKeyField) then you can find it in
there. So find the index by searching the DataKeys collection.

-Brock
DevelopMentor
http://staff.develop.com/ballen
Tks Sandy, the proble is
I don't have de index. I wrote just to watch the differences betweeen
the
index and de addressID.
So, I just have the addressID (int) and the grid like:
addressid street
1001 aaaaaaaaa
736 bbbbbbbbbb
Tks again

Fernando

"Sandy" <Sa***@discussions.microsoft.com> wrote in message
news:E5**********************************@microsof t.com...
Have you tried this?

index = DataGrid1.SelectedIndex
key = DataGrid1.DataKeys(index)
Sandy

"Fernando Lopes" wrote:
Ok Kostadin.
But, I have the AddressID, not the index of the datagrid.
index addressid street
1 1001 aaaaaaaaa
2 736 bbbbbbbbbb
Understand?

tks.

Fernando

"Kostadin Kostov" <Ko************@discussions.microsoft.com> wrote
in message
news:44**********************************@microsof t.com...

myDataGrid.SelectedIndex = myIndex;

Regards,
Kostadin Kostov
"Fernando Lopes" wrote:

> Hi there.
> I have a customer's address grid in my web application.
> After I searched for a customer I showded all his addresses.
> One of these addresses is the ship address.
> In the search, I gotten the addressId of this ship address.
> The datakey of datagrid is the AddressID.
> I want to keep selected the grid row of this address.
> How can I do that?
>
> tks.
>
> Fernando
>


Nov 19 '05 #6
Ok Brock!
Tks a lot!
Now works!
"Brock Allen" <ba****@NOSPAMdevelop.com> wrote in message
news:43**********************@msnews.microsoft.com ...
If the AddressID is in the DataGridKeys collection (meaning it was in there because you set "AddressID" as the DataKeyField) then you can find it in
there. So find the index by searching the DataKeys collection.

-Brock
DevelopMentor
http://staff.develop.com/ballen
Tks Sandy, the proble is
I don't have de index. I wrote just to watch the differences betweeen
the
index and de addressID.
So, I just have the addressID (int) and the grid like:
addressid street
1001 aaaaaaaaa
736 bbbbbbbbbb
Tks again

Fernando

"Sandy" <Sa***@discussions.microsoft.com> wrote in message
news:E5**********************************@microsof t.com...
Have you tried this?

index = DataGrid1.SelectedIndex
key = DataGrid1.DataKeys(index)
Sandy

"Fernando Lopes" wrote:

Ok Kostadin.
But, I have the AddressID, not the index of the datagrid.
index addressid street
1 1001 aaaaaaaaa
2 736 bbbbbbbbbb
Understand?

tks.

Fernando

"Kostadin Kostov" <Ko************@discussions.microsoft.com> wrote
in message
news:44**********************************@microsof t.com...

> myDataGrid.SelectedIndex = myIndex;
>
> Regards,
> Kostadin Kostov
> "Fernando Lopes" wrote:
>
>> Hi there.
>> I have a customer's address grid in my web application.
>> After I searched for a customer I showded all his addresses.
>> One of these addresses is the ship address.
>> In the search, I gotten the addressId of this ship address.
>> The datakey of datagrid is the AddressID.
>> I want to keep selected the grid row of this address.
>> How can I do that?
>>
>> tks.
>>
>> Fernando
>>


Nov 19 '05 #7
Fernando -

Try this:

Dim AddressIDIndex as Integer
Dim AddressIDKey as Integer
AddressIDIndex = NameOfYourDataGrid.SelectedIndex
AddressIDKey = NameOfYourDataGrid.DataKeys(AddressIDIndex)

Sandy

"Fernando Lopes" wrote:
Tks Sandy, the proble is
I don't have de index. I wrote just to watch the differences betweeen the
index and de addressID.

So, I just have the addressID (int) and the grid like:
addressid street
1001 aaaaaaaaa
736 bbbbbbbbbb

Tks again

Fernando

"Sandy" <Sa***@discussions.microsoft.com> wrote in message
news:E5**********************************@microsof t.com...
Have you tried this?

index = DataGrid1.SelectedIndex
key = DataGrid1.DataKeys(index)

Sandy

"Fernando Lopes" wrote:
Ok Kostadin.
But, I have the AddressID, not the index of the datagrid.

index addressid street
1 1001 aaaaaaaaa
2 736 bbbbbbbbbb

Understand?

tks.

Fernando

"Kostadin Kostov" <Ko************@discussions.microsoft.com> wrote in
message news:44**********************************@microsof t.com...
> myDataGrid.SelectedIndex = myIndex;
>
> Regards,
> Kostadin Kostov
>
> "Fernando Lopes" wrote:
>
> > Hi there.
> > I have a customer's address grid in my web application.
> > After I searched for a customer I showded all his addresses.
> > One of these addresses is the ship address.
> > In the search, I gotten the addressId of this ship address.
> > The datakey of datagrid is the AddressID.
> > I want to keep selected the grid row of this address.
> >
> > How can I do that?
> >
> > tks.
> >
> > Fernando
> >
> >
> >


Nov 19 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1750
by: Richard Loupatty | last post by:
I put a datagrid in a panel with an overflow set on auto. I want to show just 5 items in the grid. My question is how to make sure that the selecteditem is always visible in the grid. Because...
5
3513
by: Lie | last post by:
Hi all, I have problem in getting selectedindex of multiple listbox selection in a datagrid. I have a listbox with multiple selection mode inside datagrid. In Edit mode, I need to get back all...
2
2332
by: Kay Chan | last post by:
Hi All, I am going to using a editable datagrid, one of the field should be a dropdownlist, here is my code <EditItemTemplate> <asp:DropDownList ID="INVESTMENT_FUND_ID" DataSource="<%# ...
1
1169
by: Tim::.. | last post by:
Can someone please tell me who I get the selectedindex of a dropdown in a datagrid??? I have the following code and it works but it doesn't select the correct value when I edit the dropdown...
0
1415
by: js | last post by:
I have a DataGrid with a command button on the first column of the DataGrid. The DataGrid is databound to a dataset with DataKeyFiled bound to "ControlNumber" field in the dataset. I am trying to...
7
3563
by: Joel Reinford | last post by:
I am looking for a way to set the selectedindex of a datagrid based on the datakey value. For example given this grid with a datakey of OrderID: OrderID Item 54 A 98 ...
0
1176
by: brian_is_online | last post by:
Hi all, I have a DataGrid which is bound to a DataView to return search results. The DataGrid headers allow sorting so when clicked I rebind the DataView with the appropriate Sort property. To...
1
8835
by: pleaseexplaintome | last post by:
Hi all, I have a datagrid with a dropdownlist and would like to have the dropdownlist display a database value correctly while the grid is in edit mode. I have a templatecolumn as follows: ...
1
3217
by: marcbb | last post by:
Hi all, I have a really strange problem working with Dropdownlists in a DataGrid. I'm trying to preselect some values from the DropDownlist for each row in the DataGrid, but it seems that...
0
7110
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
7030
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5623
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5041
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
4702
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3191
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1540
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
411
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.