Edit GridView without using a Datasource

V

Vivek

I am having a GridView control. I am creating a datatable using code
and then the gridview control is binded to the datatable. I need to
edit the gridview control and update the datatable with the values
from the user. I have put a command field int he grid view and it
fires the gridview_row editing event, but it does not show the text
boxes as it does when it is bound to a datasource. How can i make the
textboxes to appear on gridview edit. Also.. I need to save the values
of the textboxes when I fire the gridview_row Update event. I am
sending the gridview code for reference. Please give me a solution.
Thank you...

<asp:GridView ID="gridParameter" DataKeyNames="Slno" runat="server"
AutoGenerateColumns="False" Font-Names="verdana" Font-Size="9pt"
BackColor="White" BorderColor="#DEDFDE" BorderStyle="None"
BorderWidth="1px" CellPadding="4" ForeColor="Black"
GridLines="Vertical" OnRowEditing="gridParameter_RowEditing"
OnDataBinding="gridParameter_DataBinding"
OnRowCommand="gridParameter_RowCommand"
OnRowUpdating="gridParameter_RowUpdating"
OnRowDataBound="gridParameter_RowDataBound">
<HeaderStyle Font-Size="10pt"
BackColor="#6B696B" Font-Bold="True" ForeColor="White" />
<RowStyle HorizontalAlign="Center"
BackColor="#F7F7DE" />
<Columns>
<asp:BoundField
HeaderText="Sl. No" ReadOnly="True" DataField="Slno" >
<ItemStyle
HorizontalAlign="Center" />
</
asp:BoundField>
<asp:BoundField
HeaderText="Parameters" ReadOnly="True" DataField="Parameter" >
<ItemStyle
HorizontalAlign="Left" />
</
asp:BoundField>
<asp:TemplateField
HeaderText="Prepaid" Visible="False">
<ItemStyle
HorizontalAlign="Right" />
<ItemTemplate>
<asp:Label
ID="lblPrepaid" runat="server" Text='<%# Eval("PrepaidValue") %>'></
asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox
ID="txtPrepaid" runat="server" Text='<%# Bind("PrepaidValue") %>'
Visible="false"></asp:TextBox>

<asp:RegularExpressionValidator ID="revPrepaid" runat="server"
ErrorMessage="Enter valid Number" ControlToValidate="txtPrepaid"
SetFocusOnError="True" Display="dynamic" ValidationExpression="^[+]?
\d*$" ForeColor="DarkBlue"></asp:RegularExpressionValidator>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField
HeaderText="Postpaid" Visible="False">
<ItemStyle
HorizontalAlign="Right" />
<ItemTemplate>
<asp:Label
ID="lblPostpaid" runat="server" Text='<%# Eval("PostpaidValue") %>'></
asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox
ID="txtPostpaid" runat="server" Text='<%# Bind("PostpaidValue") %>'
Visible="false"></asp:TextBox>

<asp:RegularExpressionValidator ID="revPostpaid" runat="server"
ErrorMessage="Enter valid Number" ControlToValidate="txtPostpaid"
SetFocusOnError="True" Display="dynamic" ValidationExpression="^[+]?
\d*$" ForeColor="DarkBlue"></asp:RegularExpressionValidator>
</EditItemTemplate>
</asp:TemplateField>
<asp:CommandField
ShowEditButton="true" Visible="false"/ </
Columns>
<FooterStyle BackColor="#CCCC99" / <SelectedRowStyle
BackColor="#CE5D5A" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#F7F7DE"
ForeColor="Black" HorizontalAlign="Right" />
<AlternatingRowStyle
BackColor="White" />
</asp:GridView>
 

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,983
Messages
2,570,187
Members
46,747
Latest member
jojoBizaroo

Latest Threads

Top