Thursday, March 29, 2012
Poping up a window AND redirecting the page thtat triggered the po
I have a page where the user inserts some stuff and when he clicks on the
submit button a popup window showing that info is launched and the page "A"
where he was is redirected to another page, page "B". This page "B" can also
be accessed by other means. Can this be done? If so, how?
I was trying to do this:
protected void button_Click(object sender, EventArgs e)
{
string popupScript = String.Format("<script language='javascript'>" +
"window.open('ShowReport.ashx','CustomPopUp'," +
"'width=600, height=500, menubar=no, resizable=yes,
toolbar=no,
location=no, statusbar=no, left=212, top=184')</script>");
Page.RegisterStartupScript("ShowReport", popupScript);
Page.Response.Redirect("NewPage.aspx");
}
But what happens is that I get imediatly redirected to the NewPage.aspx. If
I'm not wrong, this happens because the current page isn't reloaded after
this event is treated. What I am asking is, for the effect I want (both the
pop-up and the redirect occurs) what can I do? I have also thought on trying
to open the pop-up on the loading of NewPage.aspx, by passing some specific
value when I make the redirect (something like
Response.Redirect("NewPage.aspx?popup=yes").
Any ideas/sugestions?
Thanks in advanceHi Ricardo,
The popup window must be generated on the client. This means that the page
must be loaded to generate the popup. What you can do is to have the page
pop up a window, and then submit back to the server, where the Redirect can
occur.
HTH,
Kevin Spencer
Microsoft MVP
.Net Developer
You can lead a fish to a bicycle,
but it takes a very long time,
and the bicycle has to *want* to change.
"Ricardo Videira" <RicardoVideira@.discussions.microsoft.com> wrote in
message news:2ABEC8F1-C366-4934-BE57-01641826EA8F@.microsoft.com...
> Hi to all. I'm having trouble with the following situation:
> I have a page where the user inserts some stuff and when he clicks on the
> submit button a popup window showing that info is launched and the page
> "A"
> where he was is redirected to another page, page "B". This page "B" can
> also
> be accessed by other means. Can this be done? If so, how?
> I was trying to do this:
> protected void button_Click(object sender, EventArgs e)
> {
> string popupScript = String.Format("<script
> language='javascript'>" +
> "window.open('ShowReport.ashx','CustomPopUp'," +
> "'width=600, height=500, menubar=no, resizable=yes,
> toolbar=no,
> location=no, statusbar=no, left=212, top=184')</script>");
> Page.RegisterStartupScript("ShowReport", popupScript);
> Page.Response.Redirect("NewPage.aspx");
> }
>
> But what happens is that I get imediatly redirected to the NewPage.aspx.
> If
> I'm not wrong, this happens because the current page isn't reloaded after
> this event is treated. What I am asking is, for the effect I want (both
> the
> pop-up and the redirect occurs) what can I do? I have also thought on
> trying
> to open the pop-up on the loading of NewPage.aspx, by passing some
> specific
> value when I make the redirect (something like
> Response.Redirect("NewPage.aspx?popup=yes").
> Any ideas/sugestions?
> Thanks in advance
>
if a page has a redirect header (produced by calling Redirect), the browser
will not render the html, if you want the html rendered, you need to use a
meta tag with a refresh. also popup blocks will prevent you popup window
anyway. you should change the button to a html hyperlink that opens the
report.
-- bruce (sqlwork.com)
"Ricardo Videira" <RicardoVideira@.discussions.microsoft.com> wrote in
message news:2ABEC8F1-C366-4934-BE57-01641826EA8F@.microsoft.com...
> Hi to all. I'm having trouble with the following situation:
> I have a page where the user inserts some stuff and when he clicks on the
> submit button a popup window showing that info is launched and the page
> "A"
> where he was is redirected to another page, page "B". This page "B" can
> also
> be accessed by other means. Can this be done? If so, how?
> I was trying to do this:
> protected void button_Click(object sender, EventArgs e)
> {
> string popupScript = String.Format("<script
> language='javascript'>" +
> "window.open('ShowReport.ashx','CustomPopUp'," +
> "'width=600, height=500, menubar=no, resizable=yes,
> toolbar=no,
> location=no, statusbar=no, left=212, top=184')</script>");
> Page.RegisterStartupScript("ShowReport", popupScript);
> Page.Response.Redirect("NewPage.aspx");
> }
>
> But what happens is that I get imediatly redirected to the NewPage.aspx.
> If
> I'm not wrong, this happens because the current page isn't reloaded after
> this event is treated. What I am asking is, for the effect I want (both
> the
> pop-up and the redirect occurs) what can I do? I have also thought on
> trying
> to open the pop-up on the loading of NewPage.aspx, by passing some
> specific
> value when I make the redirect (something like
> Response.Redirect("NewPage.aspx?popup=yes").
> Any ideas/sugestions?
> Thanks in advance
>
Saturday, March 24, 2012
Populate GridView with DataSet
using the following code:
Dim sqlDapter As SqlDataAdapter
Dim dSet As DataSet
Dim dView As DataView
sqlDapter = New SqlDataAdapter(strSQL, sqlConn)
dSet = New DataSet()
dView = New DataView
sqlDapter.Fill(dSet, "Users")
dView = dSet.Tables("Users").DefaultView
dgUsers.DataSource = dView
dgUsers.DataBind()
The above works fine but I did like to bind the DataGrid to a GridView
instead of a DataView as the above code shows. What I did is deleted
the DataView from the above code & added a GridView i.e. all the
instances of the DataView were replaced with GridView i.e. changed the
variable name 'dView' to 'gView' but I get this error:
Value of type 'System.Data.DataView' cannot be converted to
'System.Web.UI.WebControls.GridView'
pointing to this line
gView = dSet.Tables("Users").DefaultView
How do I populate the GridView with the DataSet?Your DataSet and DataView variables stay the same. You will simply set
the DataSource of the GridView to your existing dView variable.
Using what you started with...
> sqlDapter.Fill(dSet, "Users")
> dView = dSet.Tables("Users").DefaultView
> dgUsers.DataSource = dView
> dgUsers.DataBind()
Assuming the GridView is named gvUsers, make the last two lines...
gvUsers.DataSource = dView
gvUsers.DataBind()
The DataGrid and GridView both take a DataView as the DataSource.
Brennan Stehling
http://brennan.offwhite.net/blog/
rn5a@.rediffmail.com wrote:
> I was using a DataView to bind records from a DB table to a DataGrid
> using the following code:
> Dim sqlDapter As SqlDataAdapter
> Dim dSet As DataSet
> Dim dView As DataView
> sqlDapter = New SqlDataAdapter(strSQL, sqlConn)
> dSet = New DataSet()
> dView = New DataView
> sqlDapter.Fill(dSet, "Users")
> dView = dSet.Tables("Users").DefaultView
> dgUsers.DataSource = dView
> dgUsers.DataBind()
> The above works fine but I did like to bind the DataGrid to a GridView
> instead of a DataView as the above code shows. What I did is deleted
> the DataView from the above code & added a GridView i.e. all the
> instances of the DataView were replaced with GridView i.e. changed the
> variable name 'dView' to 'gView' but I get this error:
> Value of type 'System.Data.DataView' cannot be converted to
> 'System.Web.UI.WebControls.GridView'
> pointing to this line
> gView = dSet.Tables("Users").DefaultView
> How do I populate the GridView with the DataSet?
Populate GridView with DataSet
using the following code:
Dim sqlDapter As SqlDataAdapter
Dim dSet As DataSet
Dim dView As DataView
sqlDapter = New SqlDataAdapter(strSQL, sqlConn)
dSet = New DataSet()
dView = New DataView
sqlDapter.Fill(dSet, "Users")
dView = dSet.Tables("Users").DefaultView
dgUsers.DataSource = dView
dgUsers.DataBind()
The above works fine but I did like to bind the DataGrid to a GridView
instead of a DataView as the above code shows. What I did is deleted
the DataView from the above code & added a GridView i.e. all the
instances of the DataView were replaced with GridView i.e. changed the
variable name 'dView' to 'gView' but I get this error:
Value of type 'System.Data.DataView' cannot be converted to
'System.Web.UI.WebControls.GridView'
pointing to this line
gView = dSet.Tables("Users").DefaultView
How do I populate the GridView with the DataSet?Your DataSet and DataView variables stay the same. You will simply set
the DataSource of the GridView to your existing dView variable.
Using what you started with...
Quote:
Originally Posted by
sqlDapter.Fill(dSet, "Users")
dView = dSet.Tables("Users").DefaultView
Quote:
Originally Posted by
dgUsers.DataSource = dView
dgUsers.DataBind()
Assuming the GridView is named gvUsers, make the last two lines...
gvUsers.DataSource = dView
gvUsers.DataBind()
The DataGrid and GridView both take a DataView as the DataSource.
Brennan Stehling
http://brennan.offwhite.net/blog/
rn5a@.rediffmail.com wrote:
Quote:
Originally Posted by
I was using a DataView to bind records from a DB table to a DataGrid
using the following code:
>
Dim sqlDapter As SqlDataAdapter
Dim dSet As DataSet
Dim dView As DataView
>
sqlDapter = New SqlDataAdapter(strSQL, sqlConn)
>
dSet = New DataSet()
dView = New DataView
>
sqlDapter.Fill(dSet, "Users")
dView = dSet.Tables("Users").DefaultView
>
dgUsers.DataSource = dView
dgUsers.DataBind()
>
The above works fine but I did like to bind the DataGrid to a GridView
instead of a DataView as the above code shows. What I did is deleted
the DataView from the above code & added a GridView i.e. all the
instances of the DataView were replaced with GridView i.e. changed the
variable name 'dView' to 'gView' but I get this error:
>
Value of type 'System.Data.DataView' cannot be converted to
'System.Web.UI.WebControls.GridView'
>
pointing to this line
>
gView = dSet.Tables("Users").DefaultView
>
How do I populate the GridView with the DataSet?
populate listbox using Javascript
document.getElementById("lsTest").Items.Add(new ListItem("Test"))
This gives following error message:
'document.getElementById(...).Items' is null or not an object
Also tried:
document.getElementById("lsTest").Add(new ListItem("Test"))
Result - Error Message:
'listitem' is undefined
Any idea?var o = document.createElement("option");
o.text = "test"
o.value = "test";
document.getElementById("lsTest").add(o);
-- bruce (sqlwork.com)
"RA" <rchaudhary-nospam@.storis.com> wrote in message
news:%23IOtEyPyEHA.2016@.TK2MSFTNGP15.phx.gbl...
| I tried following :
| document.getElementById("lsTest").Items.Add(new ListItem("Test"))
|
| This gives following error message:
| 'document.getElementById(...).Items' is null or not an object
|
| Also tried:
| document.getElementById("lsTest").Add(new ListItem("Test"))
| Result - Error Message:
| 'listitem' is undefined
|
| Any idea?
|
|
Hi RA,
you can not add a listitem from javascript. A ListBox is rendered as
html SELECT element. So, you should add the items in javascript as if you
are adding to a SELECT element, which would be like follows
document.getElementById("lsTest").add(new Option("Text","Value"));
HTH
Kumar
"RA" <rchaudhary-nospam@.storis.com> wrote in message
news:%23IOtEyPyEHA.2016@.TK2MSFTNGP15.phx.gbl...
> I tried following :
> document.getElementById("lsTest").Items.Add(new ListItem("Test"))
> This gives following error message:
> 'document.getElementById(...).Items' is null or not an object
> Also tried:
> document.getElementById("lsTest").Add(new ListItem("Test"))
> Result - Error Message:
> 'listitem' is undefined
> Any idea?
>
To remove an item from a textbox I tried;
document.getElementById("lsTest").remove(new Option("Testing","Testing"));
and
document.getElementById("lsTest").remove("Testing");
neither of above work. Both deletes very first Item in the listbox.
What I am doing wrong?
"Kumar Reddi" <KumarReddi@.REMOVETHIS.gmail.com> wrote in message
news:Odz5c8PyEHA.3096@.tk2msftngp13.phx.gbl...
> Hi RA,
> you can not add a listitem from javascript. A ListBox is rendered as
> html SELECT element. So, you should add the items in javascript as if you
> are adding to a SELECT element, which would be like follows
> document.getElementById("lsTest").add(new Option("Text","Value"));
> HTH
> Kumar
> "RA" <rchaudhary-nospam@.storis.com> wrote in message
> news:%23IOtEyPyEHA.2016@.TK2MSFTNGP15.phx.gbl...
>
populate listbox using Javascript
document.getElementById("lsTest").Items.Add(new ListItem("Test"))
This gives following error message:
'document.getElementById(...).Items' is null or not an object
Also tried:
document.getElementById("lsTest").Add(new ListItem("Test"))
Result - Error Message:
'listitem' is undefined
Any idea?var o = document.createElement("option");
o.text = "test"
o.value = "test";
document.getElementById("lsTest").add(o);
-- bruce (sqlwork.com)
"RA" <rchaudhary-nospam@.storis.com> wrote in message
news:%23IOtEyPyEHA.2016@.TK2MSFTNGP15.phx.gbl...
| I tried following :
| document.getElementById("lsTest").Items.Add(new ListItem("Test"))
|
| This gives following error message:
| 'document.getElementById(...).Items' is null or not an object
|
| Also tried:
| document.getElementById("lsTest").Add(new ListItem("Test"))
| Result - Error Message:
| 'listitem' is undefined
|
| Any idea?
|
|
Hi RA,
you can not add a listitem from javascript. A ListBox is rendered as
html SELECT element. So, you should add the items in javascript as if you
are adding to a SELECT element, which would be like follows
document.getElementById("lsTest").add(new Option("Text","Value"));
HTH
Kumar
"RA" <rchaudhary-nospam@.storis.com> wrote in message
news:%23IOtEyPyEHA.2016@.TK2MSFTNGP15.phx.gbl...
> I tried following :
> document.getElementById("lsTest").Items.Add(new ListItem("Test"))
> This gives following error message:
> 'document.getElementById(...).Items' is null or not an object
> Also tried:
> document.getElementById("lsTest").Add(new ListItem("Test"))
> Result - Error Message:
> 'listitem' is undefined
> Any idea?
To remove an item from a textbox I tried;
document.getElementById("lsTest").remove(new Option("Testing","Testing"));
and
document.getElementById("lsTest").remove("Testing");
neither of above work. Both deletes very first Item in the listbox.
What I am doing wrong?
"Kumar Reddi" <KumarReddi@.REMOVETHIS.gmail.com> wrote in message
news:Odz5c8PyEHA.3096@.tk2msftngp13.phx.gbl...
> Hi RA,
> you can not add a listitem from javascript. A ListBox is rendered as
> html SELECT element. So, you should add the items in javascript as if you
> are adding to a SELECT element, which would be like follows
> document.getElementById("lsTest").add(new Option("Text","Value"));
> HTH
> Kumar
> "RA" <rchaudhary-nospam@.storis.com> wrote in message
> news:%23IOtEyPyEHA.2016@.TK2MSFTNGP15.phx.gbl...
>> I tried following :
>> document.getElementById("lsTest").Items.Add(new ListItem("Test"))
>>
>> This gives following error message:
>> 'document.getElementById(...).Items' is null or not an object
>>
>> Also tried:
>> document.getElementById("lsTest").Add(new ListItem("Test"))
>> Result - Error Message:
>> 'listitem' is undefined
>>
>> Any idea?
>>
>>
Wednesday, March 21, 2012
Populating a Dataset
Please tell me what I'm doing wrong.
check that if the dataset is populated when there is no PostBack.
Public Overloads Function GetBookInfo() As DataSet
Dim oPubConnection As SqlConnection
Dim SConnString As String
Dim osqlCommPubs As SqlCommand
Dim osqlCommTitles As SqlCommand
Dim oDataAdapterPubs As SqlDataAdapter
Dim oDataAdapterTitles As SqlDataAdapterTry
SConnString = "Data Source=(local);Initial Catalog=Pubs;" & _
"User ID=sa;Password=;"
oPubConnection = New SqlConnection(SConnString)
oPubConnection.Open()'Create command to retrieve pub info
osqlCommPubs = New SqlCommand
osqlCommPubs.Connection = oPubConnection
osqlCommPubs.CommandText = "Select Pub_ID, Pub_Name from Publishers"'Create Data Adapter for pub info
oDataAdapterPubs = New SqlDataAdapter
oDataAdapterPubs.SelectCommand = osqlCommPubs'Create command to retrieve title info
osqlCommTitles = New SqlCommand
osqlCommTitles.Connection = oPubConnection
osqlCommPubs.CommandText = "select Pub_ID, title, price, ytd_sales from titles"'Create data adapter for title info
oDataAdapterTitles = New SqlDataAdapter
oDataAdapterTitles.SelectCommand = osqlCommTitles'Create and fill a data set
Dim datBookInfo As DataSet = New DataSet
oDataAdapterPubs.Fill(datBookInfo, "Publishers")
oDataAdapterTitles.Fill(datBookInfo, "Titles")
Return datBookInfoCatch ex As Exception
Finally
oPubConnection.Close()End Try
End Function
If(!Page.IsPostBack)
{
LoadData();
}
Hmm, dont see anything obvious...How are you doing your bind of the dataset to the grid?
Also, since this is a windows project and not a web project (assuming your "I've created a vb windows application" is correct) there will NOT be a page.isPostBack...
Thanks,
MajorCats
Populating a dropdown control
recordset and I am getting the following values in the dropdown
System.Data.DataRowView and not the expected content that should be
appearing in there. I have stepped through the code in debug mode and
examine the value of the recordset, and the right values seem to be there.
Any idea what is causing this and how to fix it so that it does not show up
like this?
.ResetParameters()
.AddParameter("iMRN", OleDb.OleDbType.Integer, ParameterDirection.Input,
ctlHeader.PatientData("PatientMRN"))
'Pull back the list of encounters for the selected patient
If .Execute(.genuSql.StoreProcSelect, "selPatient_Billing") Then
Dim oRow As DataRow
oData = .DbData_DataTable
If .DbData_DataTable.Rows.Count > 0 Then
With drpEnc
.DataSource = oData
.DataBind()
.DataValueField = "id"
.DataTextField = "DateOfService"
End With
End If
Else
Throw New Exception(.ErrorMessage)
End If 'Encounter List
J.Daly
structure:interactive
Ph: 616-364-7423
Fx: 616-364-6941
http://www.structureinteractive.comSe the DataText and DataVauleField properties BEFORE the DataBind().
DataBind() binds your source to your control, setting what to bind after
doesn't work :)
Karl
"Irishmaninusa"
<jdaly@.structuctureinteractive.com.takemeoffifyouwantoemailme> wrote in
message news:u3boxQ3iEHA.2992@.TK2MSFTNGP12.phx.gbl...
> I am trying to populate a drop down on a form with the contents of a
> recordset and I am getting the following values in the dropdown
> System.Data.DataRowView and not the expected content that should be
> appearing in there. I have stepped through the code in debug mode and
> examine the value of the recordset, and the right values seem to be there.
> Any idea what is causing this and how to fix it so that it does not show
up
> like this?
>
>
> .ResetParameters()
> .AddParameter("iMRN", OleDb.OleDbType.Integer, ParameterDirection.Input,
> ctlHeader.PatientData("PatientMRN"))
> 'Pull back the list of encounters for the selected patient
> If .Execute(.genuSql.StoreProcSelect, "selPatient_Billing") Then
> Dim oRow As DataRow
> oData = .DbData_DataTable
>
> If .DbData_DataTable.Rows.Count > 0 Then
> With drpEnc
> .DataSource = oData
> .DataBind()
> .DataValueField = "id"
> .DataTextField = "DateOfService"
> End With
> End If
> Else
> Throw New Exception(.ErrorMessage)
> End If 'Encounter List
>
> --
> J.Daly
> structure:interactive
> Ph: 616-364-7423
> Fx: 616-364-6941
> http://www.structureinteractive.com
>
>
I thought I had did that before and it still didn't work, but I tried it
again and this time it work. Now I have different issue, the stored
procedure I call pulls back date values in order, where the most recent date
is at the top and it goes back in order.
7/28/2004
7/1/2004
6/30/2004
This is the where the stored procedure pulls back the dates, which is
correct. However in the drop down it is being displayed as
7/28/2004
6/30/2004
7/1/2004
Why would this be like this?
"Karl" <karl REMOVE @. REMOVE openmymind REMOVEMETOO . ANDME net> wrote in
message news:OzuKbe3iEHA.636@.TK2MSFTNGP12.phx.gbl...
> Se the DataText and DataVauleField properties BEFORE the DataBind().
> DataBind() binds your source to your control, setting what to bind after
> doesn't work :)
> Karl
> "Irishmaninusa"
> <jdaly@.structuctureinteractive.com.takemeoffifyouwantoemailme> wrote in
> message news:u3boxQ3iEHA.2992@.TK2MSFTNGP12.phx.gbl...
there.
> up
>
I honestly don't know. I can see that you are using OLEdbClient which I'm
no expert at. Are these Date fields or string/varchar fields? you may want
to start a new thread asking this question and identifying the
database/query/schema so that someone better suited will help.
Karl
"Irishmaninusa"
<jdaly@.structuctureinteractive.com.takemeoffifyouwantoemailme> wrote in
message news:e2sIEo3iEHA.536@.TK2MSFTNGP11.phx.gbl...
> I thought I had did that before and it still didn't work, but I tried it
> again and this time it work. Now I have different issue, the stored
> procedure I call pulls back date values in order, where the most recent
date
> is at the top and it goes back in order.
> 7/28/2004
> 7/1/2004
> 6/30/2004
> This is the where the stored procedure pulls back the dates, which is
> correct. However in the drop down it is being displayed as
>
> 7/28/2004
> 6/30/2004
> 7/1/2004
> Why would this be like this?
> "Karl" <karl REMOVE @. REMOVE openmymind REMOVEMETOO . ANDME net> wrote in
> message news:OzuKbe3iEHA.636@.TK2MSFTNGP12.phx.gbl...
> there.
show
ParameterDirection.Input,
>
Thanks Karl, I will see what turns up. Thank you for your help to my earlier
issue.
"Karl" <karl REMOVE @. REMOVE openmymind REMOVEMETOO . ANDME net> wrote in
message news:umG6hJ4iEHA.1376@.TK2MSFTNGP11.phx.gbl...
> I honestly don't know. I can see that you are using OLEdbClient which I'm
> no expert at. Are these Date fields or string/varchar fields? you may
want
> to start a new thread asking this question and identifying the
> database/query/schema so that someone better suited will help.
> Karl
> "Irishmaninusa"
> <jdaly@.structuctureinteractive.com.takemeoffifyouwantoemailme> wrote in
> message news:e2sIEo3iEHA.536@.TK2MSFTNGP11.phx.gbl...
> date
in
after
in
and
> show
> ParameterDirection.Input,
>
Populating a dropdown control
recordset and I am getting the following values in the dropdown
System.Data.DataRowView and not the expected content that should be
appearing in there. I have stepped through the code in debug mode and
examine the value of the recordset, and the right values seem to be there.
Any idea what is causing this and how to fix it so that it does not show up
like this?
..ResetParameters()
..AddParameter("iMRN", OleDb.OleDbType.Integer, ParameterDirection.Input,
ctlHeader.PatientData("PatientMRN"))
'Pull back the list of encounters for the selected patient
If .Execute(.genuSql.StoreProcSelect, "selPatient_Billing") Then
Dim oRow As DataRow
oData = .DbData_DataTable
If .DbData_DataTable.Rows.Count > 0 Then
With drpEnc
..DataSource = oData
..DataBind()
..DataValueField = "id"
..DataTextField = "DateOfService"
End With
End If
Else
Throw New Exception(.ErrorMessage)
End If 'Encounter List
--
J.Daly
structure:interactive
Ph: 616-364-7423
Fx: 616-364-6941
http://www.structureinteractive.comSe the DataText and DataVauleField properties BEFORE the DataBind().
DataBind() binds your source to your control, setting what to bind after
doesn't work :)
Karl
"Irishmaninusa"
<jdaly@.structuctureinteractive.com.takemeoffifyouwa ntoemailme> wrote in
message news:u3boxQ3iEHA.2992@.TK2MSFTNGP12.phx.gbl...
> I am trying to populate a drop down on a form with the contents of a
> recordset and I am getting the following values in the dropdown
> System.Data.DataRowView and not the expected content that should be
> appearing in there. I have stepped through the code in debug mode and
> examine the value of the recordset, and the right values seem to be there.
> Any idea what is causing this and how to fix it so that it does not show
up
> like this?
>
>
> .ResetParameters()
> .AddParameter("iMRN", OleDb.OleDbType.Integer, ParameterDirection.Input,
> ctlHeader.PatientData("PatientMRN"))
> 'Pull back the list of encounters for the selected patient
> If .Execute(.genuSql.StoreProcSelect, "selPatient_Billing") Then
> Dim oRow As DataRow
> oData = .DbData_DataTable
>
> If .DbData_DataTable.Rows.Count > 0 Then
> With drpEnc
> .DataSource = oData
> .DataBind()
> .DataValueField = "id"
> .DataTextField = "DateOfService"
> End With
> End If
> Else
> Throw New Exception(.ErrorMessage)
> End If 'Encounter List
>
> --
> J.Daly
> structure:interactive
> Ph: 616-364-7423
> Fx: 616-364-6941
> http://www.structureinteractive.com
I thought I had did that before and it still didn't work, but I tried it
again and this time it work. Now I have different issue, the stored
procedure I call pulls back date values in order, where the most recent date
is at the top and it goes back in order.
7/28/2004
7/1/2004
6/30/2004
This is the where the stored procedure pulls back the dates, which is
correct. However in the drop down it is being displayed as
7/28/2004
6/30/2004
7/1/2004
Why would this be like this?
"Karl" <karl REMOVE @. REMOVE openmymind REMOVEMETOO . ANDME net> wrote in
message news:OzuKbe3iEHA.636@.TK2MSFTNGP12.phx.gbl...
> Se the DataText and DataVauleField properties BEFORE the DataBind().
> DataBind() binds your source to your control, setting what to bind after
> doesn't work :)
> Karl
> "Irishmaninusa"
> <jdaly@.structuctureinteractive.com.takemeoffifyouwa ntoemailme> wrote in
> message news:u3boxQ3iEHA.2992@.TK2MSFTNGP12.phx.gbl...
> > I am trying to populate a drop down on a form with the contents of a
> > recordset and I am getting the following values in the dropdown
> > System.Data.DataRowView and not the expected content that should be
> > appearing in there. I have stepped through the code in debug mode and
> > examine the value of the recordset, and the right values seem to be
there.
> > Any idea what is causing this and how to fix it so that it does not show
> up
> > like this?
> > .ResetParameters()
> > .AddParameter("iMRN", OleDb.OleDbType.Integer, ParameterDirection.Input,
> > ctlHeader.PatientData("PatientMRN"))
> > 'Pull back the list of encounters for the selected patient
> > If .Execute(.genuSql.StoreProcSelect, "selPatient_Billing") Then
> > Dim oRow As DataRow
> > oData = .DbData_DataTable
> > If .DbData_DataTable.Rows.Count > 0 Then
> > With drpEnc
> > .DataSource = oData
> > .DataBind()
> > .DataValueField = "id"
> > .DataTextField = "DateOfService"
> > End With
> > End If
> > Else
> > Throw New Exception(.ErrorMessage)
> > End If 'Encounter List
> > --
> > J.Daly
> > structure:interactive
> > Ph: 616-364-7423
> > Fx: 616-364-6941
> > http://www.structureinteractive.com
I honestly don't know. I can see that you are using OLEdbClient which I'm
no expert at. Are these Date fields or string/varchar fields? you may want
to start a new thread asking this question and identifying the
database/query/schema so that someone better suited will help.
Karl
"Irishmaninusa"
<jdaly@.structuctureinteractive.com.takemeoffifyouwa ntoemailme> wrote in
message news:e2sIEo3iEHA.536@.TK2MSFTNGP11.phx.gbl...
> I thought I had did that before and it still didn't work, but I tried it
> again and this time it work. Now I have different issue, the stored
> procedure I call pulls back date values in order, where the most recent
date
> is at the top and it goes back in order.
> 7/28/2004
> 7/1/2004
> 6/30/2004
> This is the where the stored procedure pulls back the dates, which is
> correct. However in the drop down it is being displayed as
>
> 7/28/2004
> 6/30/2004
> 7/1/2004
> Why would this be like this?
> "Karl" <karl REMOVE @. REMOVE openmymind REMOVEMETOO . ANDME net> wrote in
> message news:OzuKbe3iEHA.636@.TK2MSFTNGP12.phx.gbl...
> > Se the DataText and DataVauleField properties BEFORE the DataBind().
> > DataBind() binds your source to your control, setting what to bind after
> > doesn't work :)
> > Karl
> > "Irishmaninusa"
> > <jdaly@.structuctureinteractive.com.takemeoffifyouwa ntoemailme> wrote in
> > message news:u3boxQ3iEHA.2992@.TK2MSFTNGP12.phx.gbl...
> > > I am trying to populate a drop down on a form with the contents of a
> > > recordset and I am getting the following values in the dropdown
> > > > System.Data.DataRowView and not the expected content that should be
> > > appearing in there. I have stepped through the code in debug mode and
> > > examine the value of the recordset, and the right values seem to be
> there.
> > > > Any idea what is causing this and how to fix it so that it does not
show
> > up
> > > like this?
> > > > > > > > .ResetParameters()
> > > > .AddParameter("iMRN", OleDb.OleDbType.Integer,
ParameterDirection.Input,
> > > ctlHeader.PatientData("PatientMRN"))
> > > > 'Pull back the list of encounters for the selected patient
> > > > If .Execute(.genuSql.StoreProcSelect, "selPatient_Billing") Then
> > > > Dim oRow As DataRow
> > > > oData = .DbData_DataTable
> > > > > > If .DbData_DataTable.Rows.Count > 0 Then
> > > > With drpEnc
> > > > .DataSource = oData
> > > > .DataBind()
> > > > .DataValueField = "id"
> > > > .DataTextField = "DateOfService"
> > > > End With
> > > > End If
> > > > Else
> > > > Throw New Exception(.ErrorMessage)
> > > > End If 'Encounter List
> > > > > --
> > > J.Daly
> > > structure:interactive
> > > Ph: 616-364-7423
> > > Fx: 616-364-6941
> > > > http://www.structureinteractive.com
> > >
Thanks Karl, I will see what turns up. Thank you for your help to my earlier
issue.
"Karl" <karl REMOVE @. REMOVE openmymind REMOVEMETOO . ANDME net> wrote in
message news:umG6hJ4iEHA.1376@.TK2MSFTNGP11.phx.gbl...
> I honestly don't know. I can see that you are using OLEdbClient which I'm
> no expert at. Are these Date fields or string/varchar fields? you may
want
> to start a new thread asking this question and identifying the
> database/query/schema so that someone better suited will help.
> Karl
> "Irishmaninusa"
> <jdaly@.structuctureinteractive.com.takemeoffifyouwa ntoemailme> wrote in
> message news:e2sIEo3iEHA.536@.TK2MSFTNGP11.phx.gbl...
> > I thought I had did that before and it still didn't work, but I tried it
> > again and this time it work. Now I have different issue, the stored
> > procedure I call pulls back date values in order, where the most recent
> date
> > is at the top and it goes back in order.
> > 7/28/2004
> > 7/1/2004
> > 6/30/2004
> > This is the where the stored procedure pulls back the dates, which is
> > correct. However in the drop down it is being displayed as
> > 7/28/2004
> > 6/30/2004
> > 7/1/2004
> > Why would this be like this?
> > "Karl" <karl REMOVE @. REMOVE openmymind REMOVEMETOO . ANDME net> wrote
in
> > message news:OzuKbe3iEHA.636@.TK2MSFTNGP12.phx.gbl...
> > > Se the DataText and DataVauleField properties BEFORE the DataBind().
> > > > DataBind() binds your source to your control, setting what to bind
after
> > > doesn't work :)
> > > > Karl
> > > > "Irishmaninusa"
> > > <jdaly@.structuctureinteractive.com.takemeoffifyouwa ntoemailme> wrote
in
> > > message news:u3boxQ3iEHA.2992@.TK2MSFTNGP12.phx.gbl...
> > > > I am trying to populate a drop down on a form with the contents of a
> > > > recordset and I am getting the following values in the dropdown
> > > > > > System.Data.DataRowView and not the expected content that should be
> > > > appearing in there. I have stepped through the code in debug mode
and
> > > > examine the value of the recordset, and the right values seem to be
> > there.
> > > > > > Any idea what is causing this and how to fix it so that it does not
> show
> > > up
> > > > like this?
> > > > > > > > > > > > > > .ResetParameters()
> > > > > > .AddParameter("iMRN", OleDb.OleDbType.Integer,
> ParameterDirection.Input,
> > > > ctlHeader.PatientData("PatientMRN"))
> > > > > > 'Pull back the list of encounters for the selected patient
> > > > > > If .Execute(.genuSql.StoreProcSelect, "selPatient_Billing") Then
> > > > > > Dim oRow As DataRow
> > > > > > oData = .DbData_DataTable
> > > > > > > > > > If .DbData_DataTable.Rows.Count > 0 Then
> > > > > > With drpEnc
> > > > > > .DataSource = oData
> > > > > > .DataBind()
> > > > > > .DataValueField = "id"
> > > > > > .DataTextField = "DateOfService"
> > > > > > End With
> > > > > > End If
> > > > > > Else
> > > > > > Throw New Exception(.ErrorMessage)
> > > > > > End If 'Encounter List
> > > > > > > > --
> > > > J.Daly
> > > > structure:interactive
> > > > Ph: 616-364-7423
> > > > Fx: 616-364-6941
> > > > > > http://www.structureinteractive.com
> > > > > > > >
Populating a dropdown box
Hi all,
I have populated one dropdown menu using data from a database using the following code
Sub Page_Load (seander as Object, e as EventArgs) Year.DataSource = GetYear() Year.DataBind()End Sub Function GetYear() As System.Data.SqlClient.SqlDataReader Dim connectionString As String = "server='localhost'; user id='sa'; password='eoyson'; Database='PupilRoll'" Dim sqlConnection As System.Data.SqlClient.SqlConnection = New System.Data.SqlClient.SqlConnection(connectionString) Dim queryString As String = "SELECT [Years].* FROM [Years]" Dim sqlCommand As System.Data.SqlClient.SqlCommand = New System.Data.SqlClient.SqlCommand(queryString, sqlConnection) sqlConnection.Open Dim dataReader As System.Data.SqlClient.SqlDataReader = sqlCommand.ExecuteReader(System.Data.CommandBehavior.CloseConnection) Return dataReader End Function
I am now trying to populate another dropdown list depending on the information selected from the previous dropdown list.
Cheers!
Try the tutorial right on this site:
Master Detail Filtering with Two Dropdownlists
Friday, March 16, 2012
Populating data in classes
I have 2 classes, for example. I have a Company class and a contact
class.
each class has the following properties
Company
ID
Name
Town
Ref
Contact
CompanyID
FirstName
LastName
Email
Now if i am retrieving the data from my database and filling the
contact class, is it ok to populate the contacts companyname, for
example
Contact.FirstName = "XXX"
Contact.lastname = "XXX"
Contact.Company.ID = 99
Contact.Company.Name = "XXXX"
Is this best practice, or should i be doing this another way? I
thought this would make sense to do, as most of the time if i have a
contact class, i usually want to show the companyName.
Anyone know of a better way to do this, or the "best practice way"??
CheersOr maybe it would be better to write another New constructor that
accepts the ID and Name?
Contact.firstname = "ZZZ"
Contact.Lastname = "CCC"
Contact.Company = New Company(99, "CCCCC")
Is this a better option?
Yes. This is a better option. Other than that, you look fine.
"Nemisis" <darrens2005@.hotmail.comwrote in message
news:1158670936.010052.6720@.d34g2000cwd.googlegrou ps.com...
Quote:
Originally Posted by
Or maybe it would be better to write another New constructor that
accepts the ID and Name?
>
Contact.firstname = "ZZZ"
Contact.Lastname = "CCC"
>
Contact.Company = New Company(99, "CCCCC")
>
Is this a better option?
>
tdavisjr wrote:
Quote:
Originally Posted by
Yes. This is a better option. Other than that, you look fine.
>
Quote:
Originally Posted by
Contact.firstname = "ZZZ"
Contact.Lastname = "CCC"
Contact.Company = New Company(99, "CCCCC")
Is this a better option?
Tdavis,
Thanks for the reply, i do agree with you, because it looks neater, but
do you have any other reason why you think this is better?