473,385 Members | 1,942 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Best way to populate a form with a DataList link?

Hi there,

I'm a J2EE fellow who (as usual) has been thrown in the deep end and
have to learn a fair chunk of the .NET platform (VS, ADO, WebForms, C#
etc) in roughly two days. I'm doing ok so far, but am wondering on a
better way to do something...

Basically, I have a form which has a few fields the user fills in.
When submitted, the data is stored as a row in an SQL database table.
Then, I have another page which lists all the rows from that database
in tabular format. I use a DataList to do the displaying.

What I want to do is to have an "Edit" link next to each row which
will then go back to my original form, with all the fields populated
with the current values. The user can modify them, and re-submit.

I fiddled with the EditTemplate for the DataList but that's not what I
wanted - it seems to allow editing directly on my viewing only page. I
want the user to be re-directed to the separate form page. In the end,
due to a lack of time, I basically called the page with a get query
(i.e. formpage.aspx?report_id=45) and used the queryString to get the
report_id unique value of the record I wanted the fields in my form
populated with.

Anyone have a better suggestion on how to do this?

Thanks everyone,
Mal
Nov 16 '05 #1
2 3819
Hi Mal
you need to read about dataset , datatable , dataview , and datagrid
objects as i think you should use them in such situation to get the best
result . you might need to read about these on MSDN online . also i
believe you would find many good examples on this site
http://www.codeproject.com/
Mohamed Mahfouz
MEA Developer Support Center
ITworx on behalf of Microsoft EMEA GTSC.

Nov 16 '05 #2
Hi,

You need to know the "ID" of the record you selected, then with this ID you
can redirect it to the detail page and be able to fill the controls. There
are several ways of doing it, I describe you the solution more similar to
the way it was done in ASP

something like this:
... inside the DataList
<asp:button commandname="EditRecordHandler" commandargument="<%#
Container.DataItem["ID"] %>" Text="Edit"></asp:button>

and in the code behind:
protected void EditRecordHandler( object sender, CommandEventArgs e )
{
// you can also use a session variable here
Response.Redirect( "editrecord.aspx?id=" e.CommandArguments, true );
}
in the detail page you check if an ID is passed, if so you have to get this
record either from the DB or from a dataset and populate the fields as
needed.
Hope this help,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Mal P" <pa**********@hotmail.com> wrote in message
news:20*************************@posting.google.co m...
Hi there,

I'm a J2EE fellow who (as usual) has been thrown in the deep end and
have to learn a fair chunk of the .NET platform (VS, ADO, WebForms, C#
etc) in roughly two days. I'm doing ok so far, but am wondering on a
better way to do something...

Basically, I have a form which has a few fields the user fills in.
When submitted, the data is stored as a row in an SQL database table.
Then, I have another page which lists all the rows from that database
in tabular format. I use a DataList to do the displaying.

What I want to do is to have an "Edit" link next to each row which
will then go back to my original form, with all the fields populated
with the current values. The user can modify them, and re-submit.

I fiddled with the EditTemplate for the DataList but that's not what I
wanted - it seems to allow editing directly on my viewing only page. I
want the user to be re-directed to the separate form page. In the end,
due to a lack of time, I basically called the page with a get query
(i.e. formpage.aspx?report_id=45) and used the queryString to get the
report_id unique value of the record I wanted the fields in my form
populated with.

Anyone have a better suggestion on how to do this?

Thanks everyone,
Mal

Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Ian Davies | last post by:
Hello I am trying to run a few INSERT queries only if the user clicks 'continue' in a <a href> The queries takes variables created from SELECT queries. I have tried to acheive this by putting The...
2
by: Wee Bubba | last post by:
the lower part of my page consists of a dataList along with other server controls and HTML markup. this is my data display section. the upper part of my page is a data entry section. what I want...
1
by: msnews.microsoft.com | last post by:
I'd like to hear your thoughts on best methods for populating drop down list controls. I have states and countries drop down lists that don't change often, so naturally I "hard code" them in the...
10
by: Bharat | last post by:
Hi Folks, Suppose I have two link button on a page (say lnkBtn1 and lnkBtn2). On the click event of the lnkbtn1 I have to add a dynamically created control. And On the click event of the lnkBtn2 I...
2
by: Arsalan | last post by:
Well, suppose i have couple of controls in datalist and one of them is link button control how do i invoke link button controls click method in the datalist ??? Suppose link button control...
4
by: Patrick.O.Ige | last post by:
I have a CheckBoxList in a DataList and i'm trying to get item Selected after doing a postBack. I have set my CheckBoxlist AutoPostBack="True" Any ideas what 'm doing wrong? It seems not to...
0
by: Stimp | last post by:
Hi all, I have a datalist which outputs rows vertically with brief summary information for each item. When I click an item on the datalist, I set the datalist invisible and output a full page...
2
by: rn5a | last post by:
This function in a VB class file takes UserID as a parameter & returns a SqlDataReader to the calling function which exists in a ASPX page: Namespace NConnect Public Class Cart Private sqlConn...
2
by: weiwei | last post by:
Hi I am trying query the data from db and populate in the web form's textbox field. so far I cannot put that record into the text field box. anyone has idea on that, below is my sample code...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.