datagrid update

M

mike parr

I'm trying to build a datagrid similar to one found in shopping carts.
I need to have a couple of columns taken from a database query, 1 couple
where the user can enter a value in a text box(not edit a value, just
enter a value), and a button to confirm the action for that row and
update my database.

Since I'm not doing an edit, but a straight update, I'm not sure how to
trigger 1) my validation of what is entered in the text box, and 2) my
update of the database.

Here is my datagrid so far :

<asp:datagrid id="dgPersonalNumbering" runat="server"
AutoGenerateColumns="False" ForeColor="#000000"
BackColor="#dcdcdc" BorderColor="#000000"
HeaderStyle-Font-Bold="True" HeaderStyle-BackColor="#000000"
HeaderStyle-ForeColor="#FFFFFF" Font-Size="8pt"
Font-Name="arial" CellPadding="3"
OnUpdateCommand="dgPersonalNumbering_Update">
<Columns>
<asp:BoundColumn DataField="Number Type"
HeaderText="Number Type" ItemStyle-Width="90px" />
<asp:BoundColumn DataField="Description"
HeaderText="Description" ItemStyle-Width="90px" />
<asp:BoundColumn DataField="Amount Available"
HeaderText="Amount Available" ItemStyle-Width="110px" />
<asp:TemplateColumn HeaderText="Quantity Required"
ItemStyle-Width="110px">
<ItemTemplate>
<asp:TextBox id="txtQuantity" runat="server"
width="65px" MaxLength="3" Font-Name="arial" Font-Size="8pt"
ToolTip="Enter Quantity" Text='<%# DataBinder.Eval(Container.DataItem,
"Quantity Required") %>' />
<asp:requiredfieldvalidator ID="valQunatity"
ControlToValidate="txtQuantity" ErrorMessage="Please enter a Quantity"
runat="server">*</asp:requiredfieldvalidator>
<asp:RegularExpressionValidator id="valQuantityRegEx"
ErrorMessage="Please enter a valid Qunatity"
ControlToValidate="txtQuantity"
ValidationExpression="^\d?\d?\d$"
Display="Static"
runat="server">
*
</asp:RegularExpressionValidator>
</ItemTemplate>
</asp:TemplateColumn>
<asp:ButtonColumn ButtonType=LinkButton
HeaderText="Action" ItemStyle-ForeColor=Blue Text="Add To Cart"
CommandName="Update" />
</Columns>
</asp:datagrid>


Any assistance would be really appreciated.

Thanks,

Mike
 
R

Rajesh Tiwari

i am not sure its the best solution but one way to handle your problem
may be to have a submit button in each row of the datagrid and then fire
a client side event when it is clicked to check the values in other
fields.in client side event handler function you need to pass the
clientId of the controls you want to validate ....

Rajesh
 

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

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,705
Latest member
Stefkari24

Latest Threads

Top