0

I am designing a page which would look like this:

Employee Name: from db Level: from db

Hire Date: from db Service Line: from db

The next section would be for data entry Description:

For the 1st section, which control should I use? Should I use datalist for each of the 4 controls?The data would come from a package from the database, and would be data-binded in code behind.

For the 2nd section i.e. the data entry section, should I use the grid view?

Please let me know.

Thanks in advance.

1 Answer 1

1

ListViews and GridViews are for displaying a pageable list of multiple database records of the same type on a page. If you're only displaying a single record per page, use FormView if you want paging through a dataset. If you just need to display / edit a record without paging between several, use simple controls like Literals or TextBoxes or such.

Sign up to request clarification or add additional context in comments.

5 Comments

Thanks.. For the data entry piece, I want to prepopulate the fields and allow for editing. Hence wanted to know how to achieve it.
For e.g. text fields, you have to set the Text property in your Page_Load or wherever you want. Directly assigning is one way. The other way is with databinding: use <%# … #%> expressions in your .aspx` or .ascx, and call DataBind(). (This does exactly the same thing, except what gets assigned where is specified in the markup, not code, and it's done recursively. For a page / user control, what DataBind does is it evaluates databinding expressions on the page, assigns them to the correct properties, and databinds all the children of the page.)
Repeater controls are a little different. When they're data-bound, they also instantiate the templates into child controls. I also think repeater controls automatically call DataBind.
Thanks Inerdia.. I understood about the data-binding piece. If I have a grid view, I suppose I cannot add a new row? How should I achieve it? i.e. prepopulate the fields in the gridview and allow the user to add a new row?Thanks
"Databinding a GridView" means the GridView reloads data from its datasource and automatically creates child controls to display this data. So, generally, what you do is add the new data into the datasource, then call DataBind() on the GridView again. Some of this might or might not happen automatically depending on how the GridView is configured if you use its built-in support for adding new data. I highly suggest you hit the documentation for GridView and the various DataSources – I have no use for GridView in my job and am not terribly familiar with it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.