|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
SQLDataSource ValuesIs there any way to refer to the specific field values in an sqldatasource in
a formview without doing the sqldataadapater, datatable, etc.? You can access the fields values through the command object which is passed
to the event handlers. For example one might add to the markup: OnSelected ="sqldsOrderDetail_Selected" and then during handling the Selected event, one might write: void sqldsOrderDetail_Selected(object sender, SqlDataSourceStatusEventArgs e) { //get a reference to the command object used by the SqlDataSource System.Data.Common.DbCommand command = e.Command; //you can access the parameter value Response.Write(command.Parameters["@OrderID"].Value.ToString()); } Show quoteHide quote "TJHerman" wrote: > Is there any way to refer to the specific field values in an sqldatasource in > a formview without doing the sqldataadapater, datatable, etc.? You wouldn't happen to know how this is written in VB? (I'm really pushing my
luck!) Show quoteHide quote "Phillip Williams" wrote: > You can access the fields values through the command object which is passed > to the event handlers. For example one might add to the markup: > OnSelected ="sqldsOrderDetail_Selected" > > and then during handling the Selected event, one might write: > > void sqldsOrderDetail_Selected(object sender, SqlDataSourceStatusEventArgs e) > { > //get a reference to the command object used by the SqlDataSource > System.Data.Common.DbCommand command = e.Command; > //you can access the parameter value > Response.Write(command.Parameters["@OrderID"].Value.ToString()); > } > -- > HTH, > Phillip Williams > http://www.societopia.net > http://www.webswapp.com > > > "TJHerman" wrote: > > > Is there any way to refer to the specific field values in an sqldatasource in > > a formview without doing the sqldataadapater, datatable, etc.? No problem. You are welcome. It would be great if every poster indicates the
development platform and language they are using within the body of the question (e.g. ASP.NET2.0 VB would make the response more relevant) 'In this event-handling you access the parameters in the SqlDataSource Protected Sub SqlDataSource1_Selected(ByVal sender As Object, ByVal e As SqlDataSourceStatusEventArgs) Dim command As System.Data.Common.DbCommand = e.Command 'you can access the parameter value If command.Parameters.Count > 0 AndAlso Not command.Parameters("PK_ID") Is Nothing Then Response.Write(command.Parameters("@PK_ID").Value.ToString()) End If End Sub 'if you want to access any field value within the retrieved data then use the DataItem 'upon handling the FormView.DataBound event Protected Sub FormView1_DataBound(ByVal sender As Object, ByVal e As System.EventArgs) Dim frmV As FormView = DirectCast(sender, FormView) Dim drv As System.Data.DataRowView = DirectCast(frmV.DataItem, System.Data.DataRowView) Response.Write(drv("Company").ToString()) End Sub-- HTH, Phillip Williams http://www.societopia.net http://www.webswapp.com Show quoteHide quote "TJHerman" wrote: > You wouldn't happen to know how this is written in VB? (I'm really pushing my > luck!) > > "Phillip Williams" wrote: > > > You can access the fields values through the command object which is passed > > to the event handlers. For example one might add to the markup: > > OnSelected ="sqldsOrderDetail_Selected" > > > > and then during handling the Selected event, one might write: > > > > void sqldsOrderDetail_Selected(object sender, SqlDataSourceStatusEventArgs e) > > { > > //get a reference to the command object used by the SqlDataSource > > System.Data.Common.DbCommand command = e.Command; > > //you can access the parameter value > > Response.Write(command.Parameters["@OrderID"].Value.ToString()); > > } > > -- > > HTH, > > Phillip Williams > > http://www.societopia.net > > http://www.webswapp.com > > > > > > "TJHerman" wrote: > > > > > Is there any way to refer to the specific field values in an sqldatasource in > > > a formview without doing the sqldataadapater, datatable, etc.? Thank you very much! I will definitely experiment with this! I'm new to the
dotnet but with individuals like you willing to share you knowledge, I'm very encouraged! Show quoteHide quote "TJHerman" wrote: > Is there any way to refer to the specific field values in an sqldatasource in > a formview without doing the sqldataadapater, datatable, etc.?
selectedindexchanged event not firing in custom control derived from datagrid
asp.net 20 menu control useless ? [server callback, no menuitem click] CustomValidator not working in FireFox Advice Needed: Three Web controls talk to each other? maintaining viewstate in web user control GridView DataSourceID Business-Tier Class Dynamic Row Template in GridView Alternative to Hyperlinkfield? Access control from another control languages |
|||||||||||||||||||||||