Thursday, March 29, 2012
about accessing subReport's item
Is there anyone know how to access subReport's item? For example, can i use:
Reports!subReport.controls.textbox1.value in main report to access
subreport's textbox value? I have tried that, but failed. :-(
Thanks,
LisaHello Lisa,
Sadly no, I dont think you can do that.
The only property that I recall when looking at the IL that is exposed on a
ReportItem appears to be the Value property and that's I think is typed as a
String.
So on a report itself you can have a TextBox say called "TextBox1" and that
might be bound to a value from the database, and then you could bind another
TextBox to the first one with this syntax
=ReportItems!TextBox1.Value.
This kind of trick we discuss on p378 and 379 of our book where we explain
that it is useful for when you want to get image content from a DataSet into
a Report Header or Footer.
Peter Blackburn
Author: Hitchhiker's Guide to SQL Server 2000 Reporting Services
www.sqlreportingservices.net
"Lisa" <Lisa@.discussions.microsoft.com> wrote in message
news:8BDED34A-EC44-41B0-AC89-4763086BD414@.microsoft.com...
> Hi all,
> Is there anyone know how to access subReport's item? For example, can i
> use:
> Reports!subReport.controls.textbox1.value in main report to access
> subreport's textbox value? I have tried that, but failed. :-(
> Thanks,
> Lisa
Thursday, March 22, 2012
A very simple SQL question...
I don't want to use any of the big fancy Data presentation controls like GridView, Datalist, etc. I just want to do a programmatic reading of a SQL DB field and then post its contents to a label's text property. I have programmatic connection and select statements that seem to work okay. The code I have written so far is shown below. I just need to know what code should go in place of the long underlined portion...(oh, and pardon my newbie ignorance)...
<%@. Import Namespace="System.Data" %>
<%@. Import Namespace="System.Web" %>
<%@. Import Namespace="System.Web.Configuration" %>
<%@. Import Namespace="System.Web.UI" %>
<%@. Import Namespace="System.Web.UI.WebControls" %>
<script runat="server">
Sub Page_Load()
If Not IsPostBack Then
Dim PreviousContent As ContentPlaceHolder
PreviousContent = CType(PreviousPage.Controls(0).FindControl("ContentPlaceHolder_Main"), ContentPlaceHolder)
Dim PassedUserName As Label
PassedUserName = CType(PreviousContent.FindControl("lblPassedUserName"), Label)
lblPassedUserName.Text = PassedUserName.Text
Dim ASPNETDB As SqlDataSource = New SqlDataSource()
ASPNETDB.ConnectionString = WebConfigurationManager.ConnectionStrings("ASPNETDB").ConnectionString
ASPNETDB.SelectCommand = "SELECT [UserName], [LastActivityDate] FROM [vw_aspnet_Users] WHERE ([UserName] = @.UserName)"
lblUserName.Text = _____________________________________________________
End If
End Sub
</script>
This link should answer your question.
http://msdn2.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand.executescalar.aspx
Good luck
|||i guess u need a data adapter to fill the selected data inside a table.....
SqlConnection sqlconn = new SqlConnection("yourconnectionstring");
SqlCommand sqlcomd=new SqlCommad("SELECT Title FROM tbh_Categories WHERE CategoryID=@.categoryID ",sqlconn);
sqlcomd.CommandType= CommandType.Text;
sqlcomd.Parameter.Add(new SqlParameter("@.catergoryID") ,SqlDbType.NChar ,10);
sqlcomd.Parameter["@.categoryID"].Value = "your Value";
SqlDataAdapter myadp = new SqlDataAdapter(sqlcomd);
DataTable dt = new DataTable();
myadp.Fill(dt);
Label1.Text= dt.Rows[0].ItemArray.GetValue (0).ToString ();
Mark post as answer if it helped u>>>
Have a great day!
sql