Showing posts with label records. Show all posts
Showing posts with label records. Show all posts

Saturday, March 31, 2012

Submitting form doesnt update .Text

Hi!
I have this form that I use, both for adding records and for updating. When submitted, it checks if the Reuqest.Querystring("pid") i set, if not it adds a new record, otherwise it should update the current record (based on pid).
There are no problems if I add a record, but on update, the values in the form doesn't follow.
The basic structure is this:

Sub saveNews(Byval id)
'When I use this on an update, the values in name.Text and pbody.Text aren't the ones entered, but the previous values in the textboxes (or database).
If id <>""Then'Update dbElse'Add new recordEnd IfEnd SubSub btnSave()Call saveNews(Request.Querystring("pid")End Sub

Sub fEditFrm(ByVal id)
'Here I fetch the columns based on id
If objDR.HasRows Then
pbody.Text = objDR("pbody")
name.Text = objDR("name")
date_created.Text = objDR("date_created")
End If
End Sub

Sub Page.Load()'This checks which page you're onSelect Case Request.Querystring("page")Case"addnew" news.SetActiveView(editnews)Case"edit" news.SetActiveView(editnews)Call fEditFrm(Request.QueryString("pid"))'This one fetches the record and populates the textboxesEnd Sub


Is my problem understandable at all?
Thanks you alot!
/MartinI found the problem. Apparently the sub fEditFrm (which populate the form with db entry) executes before the update in saveNews(), so the textboxes reverted to the original values... I added an 'If Not Page.IsPostback' before the Call fEditFrm and it worked.
But then I have another question:
How can you check in which order things are executed? I come from classic ASP and it wasn't too hard to do things like this. Btw, I'm using VWD Express edition.

Enable tracing on the Page...

<%#@. Page Trace="true" TraceMode="SortByTime"%>

Then run the page. At the bottom you will see everything that is going on inside the page.


Thanks!
That was very useful, in Classic ASP I have this subroutine that spits out that info but this was much easier :)

Question though; is it possible to put that trace into a master page so you don't have to edit every single page?

Thanks again!
/Martin

You can enable trace for all pages in the web.config file, which looks something like this:

<configuration><web.config><trace enabled="true" traceMode="SortByTime" localOnly="false" /></web.config></configuration>

Thanks alot! I'll try it as soon as it's possible!

Saturday, March 24, 2012

Suggestions on how to ...

Can anyone suggest a good way of achieving the following;

I have a database table that contains say 30 records. I want my user to be able to view a list of all of these records and then select which ones they want to appear in a report. So they might select only one record, they might select 5 different ones. I want the records they selected to appear in one place on the screen and the others to appear elsewhere at the same time. Then they click on a button and my code uses the primary keys of only the selected records to extract data from my table.

I think you might be able to achieve this by using two listboxes side-by-side in an html table but the text that the user will need to identify the record is going to be over 200 characters long.

Thanks in advance.Have you considered using a datagrid? Do you know how to? Datagrids also allow you to wrap your text in a cell onto the next line.

Suggestions on how to Open a New Window from a data grid

I have a datagrid that holds a whole list of records about computers. I need
one column that is a hyperlink that when clicked will show the details of t
hat computer model. The hyper link needs to open in a new window and have an
address that is my page na
me (modelinfo.aspx). That part is easy, as this is built into the datagrid c
ontrol. But the last thing I need is a varible on it, so when the hyperlink
is clicked, a New page would open and have an address "modelinfo.aspx?Model=
" & what ever value is in t
he corresponding cell that was clicked. So if I clicked on Model "e20" the a
ddress bar would have to read "modelinfo.aspx?Model=e20" etc. Any suggesti
ons? Thanks
Billtry this in the datagrid..
<asp:HyperLink runat="server" Target=_blank Text='<%#
DataBinder.Eval(Container, "DataItem.Model") %>' NavigateUrl='<%#
DataBinder.Eval(Container, "DataItem.Model", "modelinfo.aspx?Model={0}"
)
%>'></asp:HyperLink>
Av.
"Bill" <anonymous@.discussions.microsoft.com> wrote in message
news:37BAE768-6513-47BE-AD69-4DC4903D4573@.microsoft.com...
>I have a datagrid that holds a whole list of records about computers. I
>need one column that is a hyperlink that when clicked will show the details
>of that computer model. The hyper link needs to open in a new window and
>have an address that is my page name (modelinfo.aspx). That part is easy,
>as this is built into the datagrid control. But the last thing I need is a
>varible on it, so when the hyperlink is clicked, a New page would open and
>have an address "modelinfo.aspx?Model=" & what ever value is in the
>corresponding cell that was clicked. So if I clicked on Model "e20" the
>address bar would have to read "modelinfo.aspx?Model=e20" etc. Any
>suggestions? Thanks
> Bill

Suggestions on how to Open a New Window from a data grid

I have a datagrid that holds a whole list of records about computers. I need one column that is a hyperlink that when clicked will show the details of that computer model. The hyper link needs to open in a new window and have an address that is my page name (modelinfo.aspx). That part is easy, as this is built into the datagrid control. But the last thing I need is a varible on it, so when the hyperlink is clicked, a New page would open and have an address "modelinfo.aspx?Model=" & what ever value is in the corresponding cell that was clicked. So if I clicked on Model "e20" the address bar would have to read "modelinfo.aspx?Model=e20" etc. Any suggestions? Thank

Billtry this in the datagrid..

<asp:HyperLink runat="server" Target=_blank Text='<%#
DataBinder.Eval(Container, "DataItem.Model") %>' NavigateUrl='<%#
DataBinder.Eval(Container, "DataItem.Model", "modelinfo.aspx?Model={0}")
%>'></asp:HyperLink
Av.

"Bill" <anonymous@.discussions.microsoft.com> wrote in message
news:37BAE768-6513-47BE-AD69-4DC4903D4573@.microsoft.com...
>I have a datagrid that holds a whole list of records about computers. I
>need one column that is a hyperlink that when clicked will show the details
>of that computer model. The hyper link needs to open in a new window and
>have an address that is my page name (modelinfo.aspx). That part is easy,
>as this is built into the datagrid control. But the last thing I need is a
>varible on it, so when the hyperlink is clicked, a New page would open and
>have an address "modelinfo.aspx?Model=" & what ever value is in the
>corresponding cell that was clicked. So if I clicked on Model "e20" the
>address bar would have to read "modelinfo.aspx?Model=e20" etc. Any
>suggestions? Thanks
> Bill