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