By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,852 Members | 1,014 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,852 IT Pros & Developers. It's quick & easy.

creating a data entry screen without the gridview.

P: n/a
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

Apr 30 '06 #1
Share this Question
Share on Google+
9 Replies


P: n/a
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

"hazz" wrote:
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

Apr 30 '06 #2

P: n/a
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

"clickon" <cl*****@discussions.microsoft.com> wrote in message
news:1E**********************************@microsof t.com...
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

"hazz" wrote:
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

Apr 30 '06 #3

P: n/a
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.
hazz wrote:
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

"clickon" <cl*****@discussions.microsoft.com> wrote in message
news:1E**********************************@microsof t.com...
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

"hazz" wrote:
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


Apr 30 '06 #4

P: n/a
"hazz" <hazz@sonic_net> wrote in message
news:eE**************@TK2MSFTNGP02.phx.gbl...
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.
Apr 30 '06 #5

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

"Flinky Wisty Pomm" <Pa********@gmail.com> wrote in message
news:11**********************@j73g2000cwa.googlegr oups.com...
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.
hazz wrote:
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

"clickon" <cl*****@discussions.microsoft.com> wrote in message
news:1E**********************************@microsof t.com...
> 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
>
> "hazz" wrote:
>
>> 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
>>
>>
>>
>>

May 1 '06 #6

P: n/a
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

"Mark Rae" <ma**@markN-O-S-P-A-M.co.uk> wrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
"hazz" <hazz@sonic_net> wrote in message
news:eE**************@TK2MSFTNGP02.phx.gbl...
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.

May 1 '06 #7

P: n/a
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
"hazz" <hazz@sonic_net> wrote in message
news:ug**************@TK2MSFTNGP03.phx.gbl...
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

"Mark Rae" <ma**@markN-O-S-P-A-M.co.uk> wrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
"hazz" <hazz@sonic_net> wrote in message
news:eE**************@TK2MSFTNGP02.phx.gbl...
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.


May 1 '06 #8

P: n/a
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/lib...ck(VS.80).aspx
"Swanand Mokashi" <sw***********@swanandmokashi.com> wrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
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
"hazz" <hazz@sonic_net> wrote in message
news:ug**************@TK2MSFTNGP03.phx.gbl...
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

"Mark Rae" <ma**@markN-O-S-P-A-M.co.uk> wrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
"hazz" <hazz@sonic_net> wrote in message
news:eE**************@TK2MSFTNGP02.phx.gbl...

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.



May 1 '06 #9

P: n/a
Sounds good -- glad could be of help :)

--
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
"hazz" <hazz@sonic_net> wrote in message
news:OU****************@TK2MSFTNGP05.phx.gbl...
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/lib...ck(VS.80).aspx
"Swanand Mokashi" <sw***********@swanandmokashi.com> wrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
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
"hazz" <hazz@sonic_net> wrote in message
news:ug**************@TK2MSFTNGP03.phx.gbl...
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

"Mark Rae" <ma**@markN-O-S-P-A-M.co.uk> wrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
"hazz" <hazz@sonic_net> wrote in message
news:eE**************@TK2MSFTNGP02.phx.gbl...

> 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.



May 1 '06 #10

This discussion thread is closed

Replies have been disabled for this discussion.