Ask a Question related to ASP.NET General, Design and Development.
-
Lewis Wang [MSFT] #1
RE: Preselecting in DataGrid
Hi Ingeborg,
You can use the primary key to locate the row. Please check the code
snippet below:
//"ds" is the dataset which will be binded to the datagrid.
ds.Tables[0].DefaultView.Sort = "id";//Sort by key
int nn=ds.Tables[0].DefaultView.Find(3);//eg: 3 is a key value of a row.
Then you can get the index of the row.
DataGrid1.EditItemIndex =nn;
DataGrid1.DataSource= dw;
DataGrid1.DataBind();
You can check the link for more information:
<[url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html[/url]
/frlrfsystemdatadataviewclassfindtopic.asp>
Hope this helps.
Best Regards,
Lewis Wang
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
| Content-Class: urn:content-classes:message
| From: "Ingeborg" <nobody@nowhere.net>
| Sender: "Ingeborg" <nobody@nowhere.net>
| Subject: Preselecting in DataGrid
| Date: Tue, 22 Jul 2003 09:22:16 -0700
| Lines: 10
| Message-ID: <011201c3506d$6a3f3350$a301280a@phx.gbl>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Thread-Index: AcNQbWo/z9kciKMYRiOlbqLmzkYWvg==
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet:161058
| NNTP-Posting-Host: TK2MSFTNGXA11 10.40.1.163
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Hi.
|
| Is it somehow possible to preselect an item in a DataGrid?
| How can you select an item in the datagrid when you only
| know what datarow you want to be selected, but need to get
| the ItemIndex for setting the DataGrid.SelectedIndex?
|
| Thanks in advance.
|
| Ingeborg
|
Lewis Wang [MSFT] Guest
-
How to add a Dropdown list to a datagrid at runtime (dynamic) without using template columns in ASP.NET and still have the ability to us the datagrid Update event.
How to add a Dropdown list to a datagrid at runtime (dynamic) without using template columns in ASP.NET and still have the ability to us the... -
UserControl inside of datagrid - loses its viewstate when datagrid is re-bound on postback
I have a simple usercontrol, a datepicker which contains 3 dropdownlist , it resides inside a datagrid column and i set the selecteddate property of... -
custom usercontrol inside of datagrid - loses its state/viewstate on re-bind/postback of the datagrid
I have a simple usercontrol, a datepicker which contains 3 dropdownlist , it resides inside a datagrid column and i set the selecteddate property of... -
How can I save the style of a datagrid so that it appears on the automatic format to use iin another datagrid?
How can I save the style of a datagrid so that it appears on the automatic format to use iin another datagrid? -
To all Gurus: How can I edit/update a DataGrid in a DataGrid (nested DataGrid)? Possible?
Hello, I am searching the whole Internet for a good example how to edit/update a DataGrid in a DataGrid (nested DataGrid). I know how to... -
Lewis Wang [MSFT] #2
RE: Preselecting in DataGrid
I am glad to hear it. Thanks very much for participating the community. ^_^
Lewis Wang
Support Professional
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
| Content-Class: urn:content-classes:message
| From: "Ingeborg" <nobody@nowhere.net>
| Sender: "Ingeborg" <nobody@nowhere.net>
| References: <011201c3506d$6a3f3350$a301280a@phx.gbl>
<Vz$mRgMUDHA.2364@cpmsftngxa06.phx.gbl>
| Subject: RE: Preselecting in DataGrid
| Date: Wed, 23 Jul 2003 11:08:34 -0700
| Lines: 74
| Message-ID: <02d901c35145$6e4f7440$a001280a@phx.gbl>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Thread-Index: AcNRRW5PE+KhL4TGQYWiCbcJdYN2kQ==
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet:161466
| NNTP-Posting-Host: TK2MSFTNGXA08 10.40.1.160
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Thanks a lot, it makes my user interface a lot nicer!
|
| Ingeborg
|
|
| >-----Original Message-----
| >Hi Ingeborg,
| >
| >You can use the primary key to locate the row. Please
| check the code
| >snippet below:
| >
| >//"ds" is the dataset which will be binded to the
| datagrid.
| >ds.Tables[0].DefaultView.Sort = "id";//Sort by key
| >int nn=ds.Tables[0].DefaultView.Find(3);//eg: 3 is a key
| value of a row.
| >Then you can get the index of the row.
| >DataGrid1.EditItemIndex =nn;
| >DataGrid1.DataSource= dw;
| >DataGrid1.DataBind();
| >
| >You can check the link for more information:
| ><[url]http://msdn.microsoft.com/library/default.asp?[/url]
| url=/library/en-us/cpref/html
| >/frlrfsystemdatadataviewclassfindtopic.asp>
| >
| >Hope this helps.
| >
| >Best Regards,
| >Lewis Wang
| >
| >This posting is provided "AS IS" with no warranties, and
| confers no rights.
| >
| >--------------------
| >| Content-Class: urn:content-classes:message
| >| From: "Ingeborg" <nobody@nowhere.net>
| >| Sender: "Ingeborg" <nobody@nowhere.net>
| >| Subject: Preselecting in DataGrid
| >| Date: Tue, 22 Jul 2003 09:22:16 -0700
| >| Lines: 10
| >| Message-ID: <011201c3506d$6a3f3350$a301280a@phx.gbl>
| >| MIME-Version: 1.0
| >| Content-Type: text/plain;
| >| charset="iso-8859-1"
| >| Content-Transfer-Encoding: 7bit
| >| X-Newsreader: Microsoft CDO for Windows 2000
| >| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| >| Thread-Index: AcNQbWo/z9kciKMYRiOlbqLmzkYWvg==
| >| Newsgroups: microsoft.public.dotnet.framework.aspnet
| >| Path: cpmsftngxa06.phx.gbl
| >| Xref: cpmsftngxa06.phx.gbl
| microsoft.public.dotnet.framework.aspnet:161058
| >| NNTP-Posting-Host: TK2MSFTNGXA11 10.40.1.163
| >| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
| >|
| >| Hi.
| >|
| >| Is it somehow possible to preselect an item in a
| DataGrid?
| >| How can you select an item in the datagrid when you
| only
| >| know what datarow you want to be selected, but need to
| get
| >| the ItemIndex for setting the DataGrid.SelectedIndex?
| >|
| >| Thanks in advance.
| >|
| >| Ingeborg
| >|
| >
| >.
| >
|
Lewis Wang [MSFT] Guest



Reply With Quote

