Home All Groups Group Topic Archive Search About
Author
8 Feb 2006 6:04 PM
Rob R. Ainscough
I'm learning how to use the GridView control -- so far I like it, however,
I've run into a significant road block.  All the data within the grid view
is NOT editable.  I have a couple of checkbox fields that I would like the
user to be able to select and/or deselect and then process some action based
on the selection of the checkbox.  It appears that in order for me to do
this, I have to provide an "edit" button for each row so the user must press
the Edit button first before they can then check/uncheck an field in my
gridview.  This approach is too worky for my users to deal with, is there
some more fluid way of having the entire gridview already in edit mode
without using the Edit button?

Thanks, Rob.

Author
8 Feb 2006 6:55 PM
Phillip Williams
Hello Rob,

The GridView allows you to define any customized layout by setting the
AutoGenerateColumns="False” and using TemplateFields. 

So for your requirements you would write TemplateFields within the GridView
that define only the EditItemTemplate, e.g,

<asp:GridView ID="GridView1" runat="server" DataSourceID="MyDataSourceID"
AutoGenerateColumns="False">
        <Columns>
            <asp:TemplateField HeaderText="MyColumnHeader">
                <EditItemTemplate>
                    <asp:TextBox ID="txtCol1" runat="server" Text='<%#
Bind("Field1Name" %>'
                        Width="70px"></asp:TextBox>
                </EditItemTemplate>
               <%-- Comment: Write as many TemplateFields as there are
columns to be displayed on your GridView --%>
            </asp:TemplateField>
        </Columns>
</asp:GridView>

Show quoteHide quote
"Rob R. Ainscough" wrote:

> I'm learning how to use the GridView control -- so far I like it, however,
> I've run into a significant road block.  All the data within the grid view
> is NOT editable.  I have a couple of checkbox fields that I would like the
> user to be able to select and/or deselect and then process some action based
> on the selection of the checkbox.  It appears that in order for me to do
> this, I have to provide an "edit" button for each row so the user must press
> the Edit button first before they can then check/uncheck an field in my
> gridview.  This approach is too worky for my users to deal with, is there
> some more fluid way of having the entire gridview already in edit mode
> without using the Edit button?
>
> Thanks, Rob.
>
>
>
Author
8 Feb 2006 7:02 PM
Phillip Williams
Actually as a correction: you will need to write those tempates as
ItemTemplates (instead of EditItemTemplates), e.g

<asp:GridView ID="GridView1" runat="server" DataSourceID="MyDataSourceID"
AutoGenerateColumns="False">
        <Columns>
            <asp:TemplateField HeaderText="MyColumnHeader">
                <ItemTemplate>
                    <asp:TextBox ID="txtCol1" runat="server" Text='<%#
Bind("Field1Name" %>'
                        Width="70px"></asp:TextBox>
                </ItemTemplate>
               <%-- Comment: Write as many TemplateFields as there are
columns to be displayed on your GridView --%>
            </asp:TemplateField>
        </Columns>
</asp:GridView>

Show quoteHide quote
"Phillip Williams" wrote:

> Hello Rob,
>
> The GridView allows you to define any customized layout by setting the
> AutoGenerateColumns="False” and using TemplateFields. 
>
> So for your requirements you would write TemplateFields within the GridView
> that define only the EditItemTemplate, e.g,
>
> <asp:GridView ID="GridView1" runat="server" DataSourceID="MyDataSourceID"
> AutoGenerateColumns="False">
>         <Columns>
>             <asp:TemplateField HeaderText="MyColumnHeader">
>                 <EditItemTemplate>
>                     <asp:TextBox ID="txtCol1" runat="server" Text='<%#
> Bind("Field1Name" %>'
>                         Width="70px"></asp:TextBox>
>                 </EditItemTemplate>
>                <%-- Comment: Write as many TemplateFields as there are
> columns to be displayed on your GridView --%>
>             </asp:TemplateField>
>         </Columns>
> </asp:GridView>
>    
> --
> HTH,
> Phillip Williams
> http://www.societopia.net
> http://www.webswapp.com
>
>
> "Rob R. Ainscough" wrote:
>
> > I'm learning how to use the GridView control -- so far I like it, however,
> > I've run into a significant road block.  All the data within the grid view
> > is NOT editable.  I have a couple of checkbox fields that I would like the
> > user to be able to select and/or deselect and then process some action based
> > on the selection of the checkbox.  It appears that in order for me to do
> > this, I have to provide an "edit" button for each row so the user must press
> > the Edit button first before they can then check/uncheck an field in my
> > gridview.  This approach is too worky for my users to deal with, is there
> > some more fluid way of having the entire gridview already in edit mode
> > without using the Edit button?
> >
> > Thanks, Rob.
> >
> >
> >
Author
8 Feb 2006 7:19 PM
Rob R. Ainscough
Phillip,

Thanks, yes I figured it out (ItemTemplate) and it permits binding to my
datasource also via custom binding i.e. Bind("myFieldName").  I don't use
DataSourceID since I don't define sqlDataSource control -- I do it all via
code behind.

Just need to make sure I can match up the checkbox selection with the
correct row...

Rob.

Show quoteHide quote
"Phillip Williams" <WEBSWAPP@newsgroups.nospam> wrote in message
news:8010C5A7-06A4-42A7-BD3E-18D20E1529AC@microsoft.com...
> Actually as a correction: you will need to write those tempates as
> ItemTemplates (instead of EditItemTemplates), e.g
>
> <asp:GridView ID="GridView1" runat="server" DataSourceID="MyDataSourceID"
> AutoGenerateColumns="False">
>        <Columns>
>            <asp:TemplateField HeaderText="MyColumnHeader">
>                <ItemTemplate>
>                    <asp:TextBox ID="txtCol1" runat="server" Text='<%#
> Bind("Field1Name" %>'
>                        Width="70px"></asp:TextBox>
>                </ItemTemplate>
>               <%-- Comment: Write as many TemplateFields as there are
> columns to be displayed on your GridView --%>
>            </asp:TemplateField>
>        </Columns>
> </asp:GridView>
>
> --
> HTH,
> Phillip Williams
> http://www.societopia.net
> http://www.webswapp.com
>
>
> "Phillip Williams" wrote:
>
>> Hello Rob,
>>
>> The GridView allows you to define any customized layout by setting the
>> AutoGenerateColumns="False" and using TemplateFields.
>>
>> So for your requirements you would write TemplateFields within the
>> GridView
>> that define only the EditItemTemplate, e.g,
>>
>> <asp:GridView ID="GridView1" runat="server" DataSourceID="MyDataSourceID"
>> AutoGenerateColumns="False">
>>         <Columns>
>>             <asp:TemplateField HeaderText="MyColumnHeader">
>>                 <EditItemTemplate>
>>                     <asp:TextBox ID="txtCol1" runat="server" Text='<%#
>> Bind("Field1Name" %>'
>>                         Width="70px"></asp:TextBox>
>>                 </EditItemTemplate>
>>                <%-- Comment: Write as many TemplateFields as there are
>> columns to be displayed on your GridView --%>
>>             </asp:TemplateField>
>>         </Columns>
>> </asp:GridView>
>>
>> --
>> HTH,
>> Phillip Williams
>> http://www.societopia.net
>> http://www.webswapp.com
>>
>>
>> "Rob R. Ainscough" wrote:
>>
>> > I'm learning how to use the GridView control -- so far I like it,
>> > however,
>> > I've run into a significant road block.  All the data within the grid
>> > view
>> > is NOT editable.  I have a couple of checkbox fields that I would like
>> > the
>> > user to be able to select and/or deselect and then process some action
>> > based
>> > on the selection of the checkbox.  It appears that in order for me to
>> > do
>> > this, I have to provide an "edit" button for each row so the user must
>> > press
>> > the Edit button first before they can then check/uncheck an field in my
>> > gridview.  This approach is too worky for my users to deal with, is
>> > there
>> > some more fluid way of having the entire gridview already in edit mode
>> > without using the Edit button?
>> >
>> > Thanks, Rob.
>> >
>> >
>> >