i have a grid view with a workorder in which half of the workorder detials are entered by the requestor and submited the other half is entered by the supervisor
So the supervisor will review the created workorder and then enter in his half soo in my gridview i created a template field called work on and its a link button soo when the supervisor clicks on this button i would like for the details view to come up as a modal pop up.
my gridview .aspx code
<asp:GridView ID="GridView1" runat="server" AllowPaging="True"
AutoGenerateColumns="False" BackColor="#39B1CC"
DataSourceID="SqlDataSource1" ForeColor="White" AllowSorting="True"
DataKeyNames="WorkOrderNum" PostBack = "True" ShowHeaderWhenEmpty="True" EmptyDataText="There were no work orders created to
be viewed at this time please create a Work Order"
onrowupdated="GridView1_RowUpdated" style="margin-right: 0px"
PageSize="12">
<Columns>
<asp:TemplateField ShowHeader="False">
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False"
CommandName="Select" onclick="LinkButton1_Click" Text="Print"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField ShowHeader="False">
<ItemTemplate>
<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="false"
CommandName="" onclick="LinkButton2_Click" Text="Work On"></asp:LinkButton>
</ItemTemplate>
<ControlStyle ForeColor="#0033CC" />
</asp:TemplateField>
<asp:BoundField DataField="WorkOrderNum" HeaderText="WorkOrderNum"
InsertVisible="False" ReadOnly="True" SortExpression="WorkOrderNum" >
<HeaderStyle Width="10px" />
</asp:BoundField>
<asp:BoundField DataField="Requestor" HeaderText="Requestor"
SortExpression="Requestor" />
<asp:BoundField DataField="Date"
HeaderText="Date" SortExpression="Date" dataformatstring="{0:MM/d/yyyy}" />
<asp:BoundField DataField="Department" HeaderText="Department"
SortExpression="Department" />
<asp:BoundField DataField="CompletionDate"
HeaderText="CompletionDate" SortExpression="CompletionDate" dataformatstring="{0:MM/d/yyyy}"/>
<asp:BoundField DataField="MachineDescription" HeaderText="MachineDescription"
SortExpression="MachineDescription" />
<asp:BoundField DataField="MachineLocation" HeaderText="MachineLocation"
SortExpression="MachineLocation" />
<asp:BoundField DataField="Type of Work Order" HeaderText="Type of Work Order"
SortExpression="Type of Work Order" />
</Columns>
</asp:GridView>
my details view.aspx
<asp:DetailsView ID="DetailsView1" runat="server" AllowPaging="True"
AutoGenerateRows="False" DataKeyNames="WorkOrderNum" BackColor="#39B1CC"
DataSourceID="SqlDataSource2" DefaultMode="Insert" Height="175px"
Width="881px" Font-Bold="True" ForeColor="White" PostBack = "True"
oniteminserted="DetailsView1_ItemInserted">
<Fields>
<asp:TemplateField HeaderText="WorkPerformed / PartsUsed"
SortExpression="column1">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("column1") %>'></asp:TextBox>
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("column1") %>' Height="29px" Width="699px"></asp:TextBox>
</InsertItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("column1") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Work Completed By " SortExpression="column2">
<EditItemTemplate>
<asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("column2") %>'></asp:TextBox>
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("column2") %>' Height="29px" Width="699px"></asp:TextBox>
</InsertItemTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("column2") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Maint. Supv. Approval" SortExpression="column3">
<EditItemTemplate>
<asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("column3") %>'></asp:TextBox>
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("column3") %>' Height="29px" Width="699px"></asp:TextBox>
</InsertItemTemplate>
<ItemTemplate>
<asp:Label ID="Label3" runat="server" Text='<%# Bind("column3") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Q.C. Inspection By" SortExpression="column4">
<EditItemTemplate>
<asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("column4") %>'></asp:TextBox>
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("column4") %>' Height="29px" Width="699px"></asp:TextBox>
</InsertItemTemplate>
<ItemTemplate>
<asp:Label ID="Label4" runat="server" Text='<%# Bind("column4") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Work_Comp_Date" SortExpression="Work_Comp_Date">
<EditItemTemplate>
<asp:TextBox ID="TextBox5" runat="server" Text='<%# Bind("Work_Comp_Date") %>'></asp:TextBox>
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="TextBox5" runat="server" Text='<%# Bind("Work_Comp_Date") %>' Height="29px" Width="699px"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Work Comp Date Date Field Required" ControlToValidate = "TextBox5"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ErrorMessage="Date format in DD/MM/YYYY" ValidationExpression = "^(0[1-9]|1[012])[-/.](0[1-9]|[12][0-9]|3[01])[-/.](19|20)\d\d$" ControlToValidate = "TextBox5"></asp:RegularExpressionValidator>
</InsertItemTemplate>
<ItemTemplate>
<asp:Label ID="Label5" runat="server" Text='<%# Bind("Work_Comp_Date") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Supv_Approval_Date"
SortExpression="Supv_Approval_Date">
<EditItemTemplate>
<asp:TextBox ID="TextBox6" runat="server"
Text='<%# Bind("Supv_Approval_Date") %>'></asp:TextBox>
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="TextBox6" runat="server"
Text='<%# Bind("Supv_Approval_Date") %>' Height="29px" Width="699px"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="Supv.Approval Date Field Required" ControlToValidate = "TextBox6"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ErrorMessage="Date format in DD/MM/YYYY" ValidationExpression = "^(0[1-9]|1[012])[-/.](0[1-9]|[12][0-9]|3[01])[-/.](19|20)\d\d$" ControlToValidate = "TextBox6"></asp:RegularExpressionValidator>
</InsertItemTemplate>
<ItemTemplate>
<asp:Label ID="Label6" runat="server" Text='<%# Bind("Supv_Approval_Date") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Maint. Supv. Approval Date"
SortExpression="column5">
<EditItemTemplate>
<asp:TextBox ID="TextBox9" runat="server" Text='<%# Bind("column5") %>'></asp:TextBox>
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="TextBox9" runat="server" Text='<%# Bind("column5") %>' Height="29px" Width="699px"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ErrorMessage="Maint.Supv.Approval Date Field Required" ControlToValidate = "TextBox9"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="RegularExpressionValidator3" runat="server" ErrorMessage="Date format in DD/MM/YYYY" ValidationExpression = "^(0[1-9]|1[012])[-/.](0[1-9]|[12][0-9]|3[01])[-/.](19|20)\d\d$" ControlToValidate = "TextBox9"></asp:RegularExpressionValidator>
</InsertItemTemplate>
<ItemTemplate>
<asp:Label ID="Label9" runat="server" Text='<%# Bind("column5") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Safety_Inspected_By"
SortExpression="Safety_Inspected_By">
<EditItemTemplate>
<asp:TextBox ID="TextBox7" runat="server"
Text='<%# Bind("Safety_Inspected_By") %>'></asp:TextBox>
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="TextBox7" runat="server"
Text='<%# Bind("Safety_Inspected_By") %>' Height="29px" Width="699px" ></asp:TextBox>
</InsertItemTemplate>
<ItemTemplate>
<asp:Label ID="Label7" runat="server" Text='<%# Bind("Safety_Inspected_By") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Status" SortExpression="Status">
<EditItemTemplate>
<asp:TextBox ID="TextBox8" runat="server" Text='<%# Bind("Status") %>'></asp:TextBox>
</EditItemTemplate>
<InsertItemTemplate>
<asp:DropDownList ID="DropDownList1" runat="server" Height="29px" Width="699px" DataTextField="Status" DataValueField = "Status" SelectedValue='<%# Bind("Status") %>'>
<asp:ListItem>New</asp:ListItem>
<asp:ListItem>Complete</asp:ListItem>
<asp:ListItem>Denied</asp:ListItem>
<asp:ListItem>Cancel</asp:ListItem>
</asp:DropDownList>
</InsertItemTemplate>
<ItemTemplate>
<asp:Label ID="Label8" runat="server" Text='<%# Bind("Status") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField ShowHeader="False">
<EditItemTemplate>
<asp:Button ID="Button1" runat="server" CausesValidation="True"
CommandName="Update" Text="Submit" />
<asp:Button ID="Button2" runat="server" CausesValidation="False"
CommandName="Cancel" Text="Cancel" />
</EditItemTemplate>
<InsertItemTemplate>
<asp:Button ID="Button1" runat="server" CausesValidation="True"
CommandName="Insert" onclick="Button1_Click" Text="Submit" />
<asp:Button ID="Button2" runat="server" CausesValidation="False"
CommandName="Cancel" Text="Cancel" />
</InsertItemTemplate>
<ItemTemplate>
<asp:Button ID="Button1" runat="server" CausesValidation="False"
CommandName="Edit" Text="Edit" />
<asp:Button ID="Button2" runat="server" CausesValidation="False"
CommandName="New" Text="New" />
</ItemTemplate>
</asp:TemplateField>
</Fields>
</asp:DetailsView>
As of now i have the detailsview1.visible = false the reason i need a pop up is because my gridview takes the entire page and i need to have the details view for the supervisor to fill out as well.
pic of my details view
so the user clicks on "Work On" and i would like for it to take the WorkOrderNum as a parameter from the gridview and set it equal in the textbox next to EnterWorkOrderNumber and if it can bring up the details view as a popup that would be awesome. I am really sorry i dont have any experience with AJAX and i looked online but everywhere are they working with buttons from outside the gridview not much help out there to call details view from gridview.
After doing a lot of googling i was able to get the details view to pop up from inside of a panel how ever the insert(submit) and cancel button are not working, and also the panel pops up in the center of the gridview can i control the popup position, i hate these controls being fixed at one place, i want to be able to place it where i marked in the red square :(
The Extra Code to accomplish the popup
.aspx
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit.HTMLEditor" TagPrefix="cc1" %>
<asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="pnl1" PopupControlID="pnl1"></asp:ModalPopupExtender>
<asp:HiddenField ID="HiddenField1" runat="server" />
<asp:Panel ID="pnl1" runat="server" Width="881px" Height="175px">
<DetailsView1>
</asp:Panel>
aspx.cs
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
ImageButton imgbtn = (ImageButton)sender;
GridViewRow GridView1 = (GridViewRow)imgbtn.NamingContainer;
string workordernum = GridView1.Cells[3].Text;
TextBox10.Text = workordernum;
ModalPopupExtender1.Show();
DetailsView1.Visible = true;
}
I finally figured out why the Detail Views Insert and Cancel events were not firing inside the details view, All i had to do was change the UseSumbitBehavior= "False"
<InsertItemTemplate>
<asp:Button ID="Button1" runat="server" CausesValidation="False"
CommandName="Insert" onclick="Button1_Click" Text="Submit" UseSubmitBehavior="False" />
<asp:Button ID="Button2" runat="server" CausesValidation="False"
CommandName="Cancel" Text="Cancel" OnClick="Button2_Click1" UseSubmitBehavior="False" />
</InsertItemTemplate>
As Far as Changing the Background to Black i was able to accomplish this by using some CSS:
<style>
.modalBackground
{
background-color:Gray;
filter:alpha(opacity=50);
opacity:0.7;
}
.pnl1BackGround
{
background-color:White;
}
To Change the Position of the PopUp i used X and Y cordinates, X to move Horizontally and Y to move Vertically.
Hope this answer helps someone out there :) Happy Coding Guys