开发者

ASP.NET: GridView and DetailsView, Do I have to have separate connections to same database?

开发者 https://www.devze.com 2023-03-12 09:28 出处:网络
I have a GV and a DV that extract data from the same database. The link between these controls is when a record in the GV is selected, the DV displays more details about that record.

I have a GV and a DV that extract data from the same database. The link between these controls is when a record in the GV is selected, the DV displays more details about that record.

Do I need separate connections? Obviously, I haven't achieved this goal and am working on it. Thanks.

CLARIFICATION so as not to waste your time:

I am asking about connection, not datasource. The reason that I am not sure the same connection can be used is that with GV, the connection doesn't have any parameter. Whereas with the DV, it needs the record ID passed to it. Or am I wrong?

Here's the link to code on the net that makes me wonder: http://asp.dotnetheaven.com/util/srcview.aspx?path=~/aspnet/samples/data/GridViewMaster开发者_Python百科Details.src

I am a novice so am still confused with the terminology. Thanks for being patient.


They can use the same datasource. (Such as an ObjectDataSource or SQLDataSource)


You can use the same data source, i.e. a DataTable. But when the Gridview row is selected you will need to find the index of the selected row and then find the DataRow from the DataTable and rebind your DetailView to that DataRow. Hope this helps.


I think that you are using Visual Studio databinding, and I would say that same Connection(DataSource) object can be used (if that is the way it goes), but I would rather suggest you avoid this design time Visual Studio programming, although it is simple and fast

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号