creating a data entry screen without the gridview.

H

hazz

I want to display 'n' records for a table-driven data entry page.
The first column should be readonly and the 2nd column, a checkbox WRITABLE
(NOT READONLY).
I can't use the gridview because it creates -> checked="checked"
disabled="disabled"
What I need is more like this;

<form id="form1" runat="server">
<div>
<table>
<tr>
<td style="width: 100px">
<asp:Label ID="Label1" runat="server" Text="Column
Name"></asp:Label></td>
<td style="width: 100px">
<asp:CheckBox ID="CheckBox1" text="Include column in
report" runat="server" /></td>
</tr>

Since all the nice and easy databinding doesn't work with the gridview, how
do I create the above html on the fly as I loop throught the sql datareader?

Thank you,
-Greg
 
G

Guest

you could use an <asp:Table> instead of an HTML table and add rows to it on
the fly. I don't understand why a GridView won't work though, you can use
template fields to display whatever you want in each column
 
H

hazz

Thank you once again. The thing I am trying to avoid with the template
fields is that I would like all checkboxes editable without having to select
an edit hyperlink with each row. I would like the user to be able to select
several editable checkboxes quickly and then have a save button to commit
all the changes at once.
I think you <asp.Table> idea is a good one. It ontakes me back to earlier
times when I used to do that. I just have to remember how to generate that
from the server side. A bunch of response.writes?
Appreciatively,
-Greg
 
F

Flinky Wisty Pomm

You can still do this with the GridView - stick a literal into your
template, and handle the databinding event.

Then set the Text of your literal to <input type="checkbox"
name="someCheckboxGroupName" value="someValue" />

Then in your button's click handler use

Request.Form["someCheckboxGroupName"]

to get the selected value.
 
M

Mark Rae

Thank you once again. The thing I am trying to avoid with the template
fields is that I would like all checkboxes editable without having to
select an edit hyperlink with each row. I would like the user to be able
to select several editable checkboxes quickly and then have a save button
to commit all the changes at once.

Following on from clickon's response, I can't see what your problem is
here...

When your page is posted back by the Save button, the value of all of the
checkboxes will be retained in ViewState - simply iterate through the page's
control collection, filter out anything which isn't a checkbox, and then
take appropriate action depending on whether each individual checkbox is
checked or not.
 
H

hazz

Thank you for the ideas! I just discovered the literal control. I'm making
some progress finally! Thanks again. -Greg

Flinky Wisty Pomm said:
You can still do this with the GridView - stick a literal into your
template, and handle the databinding event.

Then set the Text of your literal to <input type="checkbox"
name="someCheckboxGroupName" value="someValue" />

Then in your button's click handler use

Request.Form["someCheckboxGroupName"]

to get the selected value.

Thank you once again. The thing I am trying to avoid with the template
fields is that I would like all checkboxes editable without having to
select
an edit hyperlink with each row. I would like the user to be able to
select
several editable checkboxes quickly and then have a save button to commit
all the changes at once.
I think you <asp.Table> idea is a good one. It ontakes me back to earlier
times when I used to do that. I just have to remember how to generate
that
from the server side. A bunch of response.writes?
Appreciatively,
-Greg
 
H

hazz

clickon has been very helpful. I think the template fields once understood
are probably very versatile and will do everything I want. It's just taking
a few days to explore the problem and learn the controls. thanks. -greg
 
S

Swanand Mokashi

You can also use the repeater control if you don't want all the
functionality that is available with gridview or datagrid.

In a repeater control you can specify the html like you are doing right now,
and repeater is very "light" compared to a grid view or datagrid

--
Swanand Mokashi
Microsoft Certified Solution Developer (.NET) - Early Achiever
Microsoft Certified Application Developer (.NET)

http://www.dotnetgenerics.com/
DotNetGenerics.com -- anything and everything about Microsoft .NET
technology ...

http://www.swanandmokashi.com/
http://www.swanandmokashi.com/HomePage/WebServices/
Home of the Stock Quotes, Quote of the day and Horoscope web services
 
H

hazz

Thank you very much Swanand. I am actually trying that now. Here are a few
lines of my code; I am currently trying to implement the actual database
values into this repeater code that is creating the checkboxes just the way
I would like to see them. -Greg

Repeater1.HeaderTemplate = new Template(ListItemType.Header);
Repeater1.ItemTemplate = new Template(ListItemType.Item);
Repeater1.AlternatingItemTemplate = new
Template(ListItemType.AlternatingItem);
Repeater1.FooterTemplate = new Template(ListItemType.Footer);

public void InstantiateIn(System.Web.UI.Control container)
{
Literal lc = new Literal();
switch (templateType)
{
case ListItemType.Header:
lc.Text = "<TABLE border=1><TR><TH>Items</TH></TR>";
break;
case ListItemType.Item:
lc.Text = "<TR><TD>Item number: " + itemcount.ToString() +
"</TD>";
break;
case ListItemType.AlternatingItem:
lc.Text = "<TD> <input type= checkbox name=
someCheckboxGroupName value= someValue /> " + "</TD></TR>";
break;
case ListItemType.Footer:
lc.Text = "</TABLE>";
break;
}
container.Controls.Add(lc);

based on http://msdn2.microsoft.com/en-us/library/0e39s2ck(VS.80).aspx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top