/button.aspx Secret
Last active
December 10, 2017 06:05
Star
You must be signed in to star a gist
AspGridView_WithCustomeColumn_For_TextBox
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected void aspGridView_RowCommand(object sender, GridViewCommandEventArgs e) | |
{ | |
int rowIndex = 0; | |
string ordernum = string.Empty; | |
string approverid = string.Empty; | |
UpdateData updateDataInDb = null; | |
try | |
{ | |
switch (e.CommandName) | |
{ | |
case "ApproveOrder": | |
rowIndex = Convert.ToInt32(e.CommandArgument); | |
GridViewRow row = aspGridView.Rows[rowIndex]; | |
approverid = ((TextBox)row.FindControl("txtApproveId")).Text.ToString().Trim(); | |
ordernum = row.Cells[0].Text.ToString().Trim(); | |
updateDataInDb = new UpdateData(); | |
updateDataInDb.UpdateApproverId(ordernum, approverid); | |
break; | |
} | |
} | |
catch (Exception ex) | |
{ | |
throw ex; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected void aspGridView_RowDataBound(object sender, GridViewRowEventArgs e) | |
{ | |
Button approveOrderBtn = null; | |
Button clearnBtn = null; | |
DataRowView datarow = null; | |
Label approvedBy = null; | |
Label alertText = null; | |
TextBox approvalid = null; | |
HtmlGenericControl approvalSection = null; | |
try | |
{ | |
if (e.Row.RowType == DataControlRowType.DataRow) | |
{ | |
datarow = (DataRowView)e.Row.DataItem; | |
if (!string.IsNullOrEmpty(datarow[5].ToString())) | |
{ | |
approvalSection = (HtmlGenericControl)e.Row.FindControl("ApprovalSection"); | |
approvalSection.Visible = false; | |
approvedBy = (Label)e.Row.FindControl("txtapprovedBy"); | |
approvedBy.Visible = true; | |
} | |
else | |
{ | |
approveOrderBtn = (Button)e.Row.FindControl("btnApproveOrder"); | |
clearnBtn = (Button)e.Row.FindControl("btnClear"); | |
alertText = (Label)e.Row.FindControl("alertMsg"); | |
approvalid = (TextBox)e.Row.FindControl("txtApproveId"); | |
if (approveOrderBtn != null) | |
approveOrderBtn.OnClientClick = "return ValidateInput('" + approvalid.ClientID + "','" + alertText.ClientID + "')"; | |
if (clearnBtn!=null) | |
clearnBtn.OnClientClick= "return ClearInputField('"+approvalid.ClientID+"')"; | |
} | |
} | |
} | |
catch (Exception ex) | |
{ | |
throw ex; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<asp:GridView ID="aspGridView" runat="server" AutoGenerateColumns="false" Width="100%" style="margin-top:20px;" OnRowCommand="aspGridView_RowCommand" OnRowDataBound="aspGridView_RowDataBound"> | |
<Columns> | |
<asp:BoundField HeaderText="Order Number" DataField="ORD_NUM" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center" /> | |
<asp:BoundField HeaderText="Order Amount" DataField="ORD_AMOUNT" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center" /> | |
<asp:BoundField HeaderText="Order Date" DataField="ORD_DATE" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center" /> | |
<asp:BoundField HeaderText="Customer Date" DataField="CUST_NAME" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center" /> | |
<asp:BoundField HeaderText="Order Description" DataField="ORD_DESCRIPTION" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center" /> | |
<asp:TemplateField HeaderText="Approve Order"> | |
<ItemTemplate> | |
<section id="ApprovalSection" runat="server" style="margin-top: 5px;"> | |
<div class="approveUserIdSection"> | |
<asp:TextBox ID="txtApproveId" ClientIDMode="Predictable" | |
placeholder="Approver ID" | |
runat="server" | |
MaxLength="11"></asp:TextBox> | |
<asp:Label ID="alertMsg" | |
ClientIDMode="Predictable" | |
runat="server" | |
CssClass="validatorMsgGrid"></asp:Label> | |
</div> | |
<div> | |
<asp:Button ID="btnApproveOrder" ClientIDMode="Predictable" Text="Approve Order" runat="server" CssClass="button" CommandName="ApproveOrder" CommandArgument="<%#((GridViewRow)Container).RowIndex %>" /> | |
<asp:Button ID="btnClear" ClientIDMode="Predictable" Text="Clear" runat="server" CssClass="button" /> | |
</div> | |
</section> | |
<asp:Label ID="txtapprovedBy" runat="server" Visible="false" Text='<%# "Approved By " + Eval("APPROVAL_ID") %>' CssClass="approvedByMsg"></asp:Label> | |
</ItemTemplate> | |
</asp:TemplateField> | |
</Columns> | |
</asp:GridView> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment