.NET Delete in ListView isn't passing any values - c#

For some reason, all my ListView functions work, except my delete button. I have debugged, and it points to the right method for deletion, but it's just passing all null values. I have no idea what the issue is, everything else seems to be working just fine. here is my listview code:
<asp:ListView ID="EntReqListView" runat="server" InsertItemPosition="LastItem" DataSourceID="EntranceReqODS" Visible="false">
<AlternatingItemTemplate>
<tr style="">
<td>
<asp:Button ID="DeleteButton" runat="server" CommandName="Delete" Text="Delete" />
<asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Edit" />
</td>
<td>
<asp:Label ID="ProgramIDLabel" runat="server" Text='<%# Bind("ProgramID") %>' />
</td>
<td>
<asp:Label ID="CourseIDLabel" runat="server" Text='<%# Bind("CourseID") %>' />
</td>
<td>
<asp:Label ID="CourseNameLabel" runat="server" Text='<%# Bind("CourseName") %>' />
</td>
<td>
<asp:Label ID="MarkLabel" runat="server" Text='<%# Bind("Mark") %>' />
</td>
</tr>
</AlternatingItemTemplate>
<EditItemTemplate>
<tr style="">
<td>
<asp:Button ID="UpdateButton" runat="server" CommandName="Update" Text="Update" />
<asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Cancel" />
</td>
<td>
<asp:Label ID="ProgramIDTextBox" runat="server" Text='<%# Bind("ProgramID") %>' />
</td>
<td>
<asp:Label ID="CourseIDTextBox" runat="server" Text='<%# Bind("CourseID") %>' />
</td>
<td>
<asp:Label ID="CourseNameTextBox" runat="server" Text='<%# Bind("CourseName") %>' />
</td>
<td>
<asp:TextBox ID="MarkTextBox" runat="server" Text='<%# Bind("Mark") %>' />
</td>
</tr>
</EditItemTemplate>
<EmptyDataTemplate>
<table runat="server" style="">
<tr>
<td>No data was returned.</td>
</tr>
</table>
</EmptyDataTemplate>
<InsertItemTemplate>
<tr style="">
<td>
<asp:Button ID="InsertButton" runat="server" CommandName="Insert" Text="Insert"/>
<asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Clear" />
</td>
<td>
<asp:TextBox ID="ProgramIDTextBox" runat="server" value="<%# ProgramID.Text %>" Text='<%# Bind("ProgramID")%>' onkeydown="javascript:return false"/>
</td>
<td>
<asp:Label ID="CourseIDTextBox" runat="server" Text='<%# Bind("CourseID") %>' />
</td>
<td>
<asp:DropDownList ID="EntReqCourses" runat="server"
DataSourceID="CourseListODS"
DataTextField="SubjectName"
DataValueField="CourseID"
SelectedValue='<%# Bind("CourseID") %>' AppendDataBoundItems="True">
<asp:ListItem Text="--Select One--" Value="" />
</asp:DropDownList>
</td>
<td>
<asp:TextBox ID="MarkTextBox" runat="server" Text='<%# Bind("Mark") %>' />
</td>
</tr>
</InsertItemTemplate>
<ItemTemplate>
<tr style="">
<td>
<asp:Button ID="DeleteButton" runat="server" CommandName="Delete" Text="Delete" />
<asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Edit" />
</td>
<td>
<asp:Label ID="ProgramIDLabel" runat="server" Text='<%# Bind("ProgramID") %>' />
</td>
<td>
<asp:Label ID="CourseIDLabel" runat="server" Text='<%# Bind("CourseID") %>' />
</td>
<td>
<asp:Label ID="CourseNameLabel" runat="server" Text='<%# Bind("CourseName") %>' />
</td>
<td>
<asp:Label ID="MarkLabel" runat="server" Text='<%# Bind("Mark") %>' />
</td>
</tr>
</ItemTemplate>
<LayoutTemplate>
<table runat="server">
<tr runat="server">
<td runat="server">
<table id="itemPlaceholderContainer" runat="server" border="0" style="">
<tr runat="server" style="">
<th runat="server"></th>
<th runat="server">ProgramID</th>
<th runat="server">CourseID</th>
<th runat="server">CourseName</th>
<th runat="server">Mark</th>
</tr>
<tr id="itemPlaceholder" runat="server">
</tr>
</table>
</td>
</tr>
<tr runat="server">
<td runat="server" style="">
<asp:DataPager ID="DataPager1" runat="server">
<Fields>
<asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True" ShowLastPageButton="True" />
</Fields>
</asp:DataPager>
</td>
</tr>
</table>
</LayoutTemplate>
<SelectedItemTemplate>
<tr style="">
<td>
<asp:Button ID="DeleteButton" runat="server" CommandName="Delete" Text="Delete" />
<asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Edit" />
</td>
<td>
<asp:Label ID="ProgramIDLabel" runat="server" Text='<%# Bind("ProgramID") %>' />
</td>
<td>
<asp:Label ID="CourseIDLabel" runat="server" Text='<%# Bind("CourseID") %>' />
</td>
<td>
<asp:Label ID="CourseNameLabel" runat="server" Text='<%# Bind("CourseName") %>' />
</td>
<td>
<asp:Label ID="MarkLabel" runat="server" Text='<%# Bind("Mark") %>' />
</td>
</tr>
</SelectedItemTemplate>
</asp:ListView>
I set up all my CRUD methods through the wizard, here is the delete method it goes to:
[DataObjectMethod(DataObjectMethodType.Delete, false)]
public void EntReq_Delete(EntranceRequirementInfo item)
{
using (Pathway_Model context = new Pathway_Model())
{
EntranceRequirement existing = context.EntranceRequirements.Find(item.CourseID, item.ProgramID);
context.EntranceRequirements.Remove(existing);
context.SaveChanges();
}
}
My ODS:
<asp:ObjectDataSource ID="EntranceReqODS" runat="server" DataObjectTypeName="Pathway_System.Entities.DTOs.EntranceRequirementInfo" DeleteMethod="EntReq_Delete" InsertMethod="EntReq_Add" OldValuesParameterFormatString="original_{0}" SelectMethod="EntReqList_byID" TypeName="Pathway_System.BLL.PathwaysController" UpdateMethod="EntReq_Update">
<SelectParameters>
<asp:ControlParameter ControlID="CertificateList" Name="programID" PropertyName="SelectedValue" Type="Int32" DefaultValue="" />
</SelectParameters>
</asp:ObjectDataSource>

Related

ListView CheckBox issue

I'm having a ListView in grid format which comprises headers as (NAME,ID,ADDRESS,GENDER,MOBILENO,PHOTO,BLOCK).
The BLOCK column consists a CheckBox in each row.
When the checkbox is checked in the BLOCK column,
that particular row of the checkbox should be changed to ReadOnly,
resulting in change of that particular row's backcolor.
my listview coding in aspx is...
<AlternatingItemTemplate>
<tr class="AITtr">
<td>
<asp:Label ID="NAMELabel" runat="server" Text='<%# Eval("NAME") %>' />
</td>
<td>
<asp:Label ID="IDLabel" runat="server" Text='<%# Eval("ID") %>' />
</td>
<td>
<asp:Label ID="ADDRESSLabel" runat="server" Text='<%# Eval("ADDRESS") %>' />
</td>
<td>
<asp:Label ID="GENDERLabel" runat="server" Text='<%# Eval("GENDER") %>' />
</td>
<td>
<asp:Label ID="MOBILENOLabel" runat="server" Text='<%# Eval("MOBILENO") %>' />
</td>
<td>
<asp:Image ID="Image1" runat="server" ImageUrl='<%#Eval("PHOTO") %>' Height="30" Width="30" />
</td>
<td>
<asp:CheckBox ID="BLOCKCheckBox" runat="server" Checked="false" Enabled="true" />
</td>
<td>
<asp:Button ID="DeleteButton" runat="server" CommandName="Delete" Text="Delete" BackColor="#577109" ForeColor="Black" BorderStyle="Solid" Font-Names="Copperplate Gothic Light" />
<asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Edit" BackColor="#577109" ForeColor="Black" BorderStyle="Solid" Font-Names="Copperplate Gothic Light"/>
</td>
</tr>
</AlternatingItemTemplate>
<EditItemTemplate>
<tr class="EITtr">
<td>
<asp:TextBox ID="NAMETextBox" runat="server" Text='<%# Bind("NAME") %>' />
</td>
<td>
<asp:Label ID="IDLabel1" runat="server" Text='<%# Eval("ID") %>' />
</td>
<td>
<asp:TextBox ID="ADDRESSTextBox" runat="server" Text='<%# Bind("ADDRESS") %>' />
</td>
<td>
<asp:TextBox ID="GENDERTextBox" runat="server" Text='<%# Bind("GENDER") %>' />
</td>
<td>
<asp:TextBox ID="MOBILENOTextBox" runat="server" Text='<%# Bind("MOBILENO") %>' />
</td>
<td>
<asp:TextBox ID="PHOTOTextBox" runat="server" Text='<%# Bind("PHOTO") %>' />
</td>
<td>
<asp:CheckBox ID="BLOCKCheckBox" runat="server" Checked="false" Enabled="true" />
</td>
<td>
<asp:Button ID="UpdateButton" runat="server" CommandName="Update"
Text="Update" BackColor="#577109" ForeColor="Black" BorderStyle="Solid" Font-Names="Copperplate Gothic Light" />
<asp:Button ID="CancelButton" runat="server" CommandName="Cancel"
Text="Cancel" BackColor="#577109" ForeColor="Black" BorderStyle="Solid" Font-Names="Copperplate Gothic Light" />
</td>
</tr>
</EditItemTemplate>
<EmptyDataTemplate>
<table runat="server" class="EDTtable" >
<tr>
<td>
No data was returned.</td>
</tr>
</table>
</EmptyDataTemplate>
<InsertItemTemplate>
<tr>
<td>
<asp:TextBox ID="NAMETextBox" runat="server" Text='<%# Bind("NAME") %>' />
</td>
<td>
</td>
<td>
<asp:TextBox ID="ADDRESSTextBox" runat="server" Text='<%# Bind("ADDRESS") %>' />
</td>
<td>
<asp:TextBox ID="GENDERTextBox" runat="server" Text='<%# Bind("GENDER") %>' />
</td>
<td>
<asp:TextBox ID="MOBILENOTextBox" runat="server" Text='<%# Bind("MOBILENO") %>' />
</td>
<td>
<asp:TextBox ID="PHOTOTextBox" runat="server" Text='<%# Bind("PHOTO") %>' />
</td>
<td>
<asp:CheckBox ID="BLOCKCheckBox" runat="server" Checked="false" Enabled="true" />
</td>
<td>
<asp:Button ID="InsertButton" runat="server" CommandName="Insert"
Text="Insert" BackColor="#577109" ForeColor="Black" BorderStyle="Solid" Font-Names="Copperplate Gothic Light"/>
<asp:Button ID="CancelButton1" runat="server" CommandName="Cancel"
Text="Clear" BackColor="#577109" ForeColor="Black" BorderStyle="Solid" Font-Names="Copperplate Gothic Light" />
</td>
</tr>
</InsertItemTemplate>
<ItemTemplate>
<tr class="ITtr">
<td>
<asp:Label ID="NAMELabel" runat="server" Text='<%# Eval("NAME") %>' />
</td>
<td>
<asp:Label ID="IDLabel" runat="server" Text='<%# Eval("ID") %>' />
</td>
<td>
<asp:Label ID="ADDRESSLabel" runat="server" Text='<%# Eval("ADDRESS") %>' />
</td>
<td>
<asp:Label ID="GENDERLabel" runat="server" Text='<%# Eval("GENDER") %>' />
</td>
<td>
<asp:Label ID="MOBILENOLabel" runat="server" Text='<%# Eval("MOBILENO") %>' />
</td>
<td>
<asp:Image ID="Image" runat="server" ImageUrl='<%#Eval("PHOTO") %>' Height="30" Width="30" />
</td>
<td>
<asp:CheckBox ID="BLOCKCheckBox" runat="server" Checked="false" Enabled="true" />
</td>
<td>
<asp:Button ID="DeleteButton1" runat="server" CommandName="Delete"
Text="Delete" BackColor="#577109" ForeColor="Black" BorderStyle="Solid" Font-Names="Copperplate Gothic Light" />
<asp:Button ID="EditButton1" runat="server" CommandName="Edit" Text="Edit" BackColor="#577109" ForeColor="Black" BorderStyle="Solid" Font-Names="Copperplate Gothic Light"/>
</td>
</tr>
</ItemTemplate>
<LayoutTemplate>
<table runat="server">
<tr runat="server">
<td runat="server">
<table ID="itemPlaceholderContainer" runat="server" border="1" class="LTtable" >
<tr runat="server" Class="LTtr">
<th runat="server">
NAME</th>
<th runat="server">
ID</th>
<th runat="server">
ADDRESS</th>
<th runat="server">
GENDER</th>
<th runat="server">
MOBILENO</th>
<th runat="server">
PHOTO</th>
<th runat="server">
BLOCK</th>
<th id="Th1" runat="server">
</th>
</tr>
<tr ID="itemPlaceholder" runat="server">
</tr>
</table>
</td>
</tr>
<tr runat="server">
<td runat="server" class="LTtd">
</td>
</tr>
</table>
</LayoutTemplate>
<SelectedItemTemplate>
<tr Class=".SITtr">
<td>
<asp:Label ID="NAMELabel" runat="server" Text='<%# Eval("NAME") %>' />
</td>
<td>
<asp:Label ID="IDLabel" runat="server" Text='<%# Eval("ID") %>' />
</td>
<td>
<asp:Label ID="ADDRESSLabel" runat="server" Text='<%# Eval("ADDRESS") %>' />
</td>
<td>
<asp:Label ID="GENDERLabel" runat="server" Text='<%# Eval("GENDER") %>' />
</td>
<td>
<asp:Label ID="MOBILENOLabel" runat="server" Text='<%# Eval("MOBILENO") %>' />
</td>
<td>
<asp:Label ID="PHOTOLabel" runat="server" Text='<%# Eval("PHOTO") %>' />
</td>
<td>
<asp:CheckBox ID="BLOCKCheckBox" runat="server" Checked="false" Enabled="true" />
</td>
<td>
<asp:Button ID="DeleteButton2" runat="server" CommandName="Delete"
Text="Delete" BackColor="#577109" ForeColor="Black" BorderStyle="Solid" Font-Names="Copperplate Gothic Light" />
<asp:Button ID="EditButton2" runat="server" CommandName="Edit" Text="Edit" BackColor="#577109" ForeColor="Black" BorderStyle="Solid" Font-Names="Copperplate Gothic Light"/>
</td>
</tr>
</SelectedItemTemplate>
</asp:ListView>
my aspx.cs coding is....
protected void ListView1_OnItemDataBound(object sender, ListViewItemEventArgs e)
{
if (e.Item.ItemType == ListViewItemType.DataItem)
{
CheckBox BLOCKCheckBox = (e.Item.FindControl("BLOCKCheckBox") as CheckBox);
if (BLOCKCheckBox.Checked)
{
}
else
{
}
}
}
Kindly help me.....
Thanks....
add oncheckedChanged for block check box and autopostback=true
aspx.cs
protected void BLOCKCheckBox_CheckedChanged(object sender, EventArgs e)
{
CheckBox checkbox = (CheckBox)sender;
ListViewItem itm = (ListViewItem)checkbox.NamingContainer;
if (lstview1.EditIndex == itm.DisplayIndex)
{
(itm.FindControl("NAMETextBox") as TextBox).ReadOnly = true;
}
}

TextBox in the RadGrid control doesn't make partial postback and fills the other controls

I have a TextBox (named as txt_lect_in) in RadGrid and I handled the TextBox changed event so it fills other textboxes (gv_txt_name,gv_txt_mobile,gv_txt_address,gv_txt_email) in the same grid.
The problem is:
The TextBox (txt_lect_in) doesn't fills the other textboxes, I know the reason but I don't know how to fix it.
After I remove the RadAjaxManager, it fills the other textboxes in the grid but it does full post back, how to keep the ajax manager and fill the controls at the same time?
<telerik:radajaxmanager id="RadAjaxManager1" runat="server">
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="gv_about">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="gv_about" LoadingPanelID="RadAjaxLoadingPanel1">
</telerik:AjaxUpdatedControl>
<telerik:AjaxUpdatedControl ControlID="divMsgs"></telerik:AjaxUpdatedControl>
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
</telerik:radajaxmanager>
<telerik:radajaxloadingpanel id="RadAjaxLoadingPanel1" runat="server">
</telerik:radajaxloadingpanel>
<telerik:radgrid id="gv_about" runat="server" cssclass="RadGrid" allowpaging="True"
pagesize="20" allowsorting="True" autogeneratecolumns="False" showstatusbar="True"
allowautomaticdeletes="True" allowautomaticinserts="True" allowautomaticupdates="True"
datasourceid="ObjectDataSource1" onitemdeleted="gv_about_ItemDeleted" oniteminserted="gv_about_ItemInserted"
onitemupdated="gv_about_ItemUpdated" onitemcommand="gv_about_ItemCommand" onprerender="gv_about_PreRender"
onitemcreated="gv_about_ItemCreated">
<MasterTableView CommandItemDisplay="Top" DataSourceID="ObjectDataSource1">
<commanditemsettings addnewrecordtext="اضافة" showrefreshbutton="False" />
<Columns>
<telerik:GridEditCommandColumn>
</telerik:GridEditCommandColumn>
<telerik:GridBoundColumn UniqueName="emp_num" HeaderText="رقم المحاضر" DataField="emp_num">
<HeaderStyle ForeColor="Silver" Width="25px"></HeaderStyle>
<ItemStyle ForeColor="Gray"></ItemStyle>
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="name" HeaderText="الاسم" DataField="name">
<HeaderStyle Width="220px"></HeaderStyle>
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="degree_name" HeaderText="الدرجة العلمية" DataField="degree_name">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="college" HeaderText="الكلية والجامعة" DataField="college">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="type" HeaderText="نوع المحاضر" DataField="type">
</telerik:GridBoundColumn>
<telerik:GridButtonColumn CommandName="Delete" Text="حذف" UniqueName="column">
</telerik:GridButtonColumn>
</Columns>
<EditFormSettings EditFormType="Template">
<EditColumn UniqueName="EditCommandColumn1" FilterControlAltText="Filter EditCommandColumn1 column"></EditColumn>
<FormTemplate>
<table id="Table2" cellspacing="2" cellpadding="1" width="100%" border="0" rules="none"
style="border-collapse: collapse;" >
<tr class="EditFormHeader">
<td colspan="2" style="font-size: small">
<b>استمارة تعارف</b>
</td>
</tr>
<tr>
<td>
<table id="Table3" cellspacing="1" cellpadding="1" width="250" border="0" class="module">
<tr>
<td>
نوع المحاضر:
</td>
<td>
<div id="div_lect_type">
<asp:RadioButtonList ID="rbt_lect_type" runat="server" AppendDataBoundItems="true"
AutoPostBack="true" CausesValidation="false" RepeatDirection="Horizontal" OnSelectedIndexChanged="rbt_lect_type_SelectedIndexChanged">
<asp:ListItem Value="1" Text="معين" Selected="True"></asp:ListItem>
<asp:ListItem Value="2" Text="منتدب خارجي"></asp:ListItem>
<asp:ListItem Value="3" Text="جديد"></asp:ListItem>
</asp:RadioButtonList>
</div>
<div id="div_lect">
<asp:TextBox ID="txt_lect_in" runat="server" AutoPostBack="True" OnTextChanged="txt_lect_in_TextChanged"></asp:TextBox>
<asp:AutoCompleteExtender ID="txt_lect_in_AutoCompleteExtender" runat="server" DelimiterCharacters=""
Enabled="True" MinimumPrefixLength="4" ServiceMethod="Get_Emp_AutoComplete" ServicePath="~/LectIn.asmx"
TargetControlID="txt_lect_in" BehaviorID="ACE_txt_lect_in" CompletionListCssClass="autocomplete_completionListElement"
CompletionListHighlightedItemCssClass="autocomplete_highlightedListItem" CompletionListItemCssClass="autocomplete_listItem"
EnableCaching="False">
</asp:AutoCompleteExtender>
</div>
</td>
</tr>
<tr>
<td>
الاسم:
</td>
<td>
<asp:TextBox ID="gv_txt_name" runat="server" Text='<%# Eval("name") %>' TabIndex="1">
</asp:TextBox>
</td>
</tr>
<tr>
<td>
الموبايل:
</td>
<td>
<telerik:RadMaskedTextBox ID="gv_txt_mobile" runat="server" SelectionOnFocus="SelectAll"
Text='<%# Bind("tel_num") %>' PromptChar="_" Width="300px" Mask="(###)_########"
TabIndex="2">
</telerik:RadMaskedTextBox>
</td>
</tr>
<tr>
<td>
عنوان المراسلات:
</td>
<td>
<asp:TextBox ID="gv_txt_address" runat="server" Text='<%# Eval("address") %>' TabIndex="3">
</asp:TextBox>
</td>
</tr>
<tr>
<td>
البريد الإلكتروني:
</td>
<td>
<asp:TextBox ID="gv_txt_email" runat="server" Text='<%# Eval("email") %>' TabIndex="4">
</asp:TextBox>
</td>
</tr>
<tr>
<td>
الدرجة العلمية:
</td>
<td>
<asp:TextBox ID="gv_txt_degree" runat="server" Text='<%# Eval("degree_name") %>' TabIndex="5">
</asp:TextBox>
</td>
</tr>
<tr>
<td>
الكلية والجامعة:
</td>
<td>
<%-- <asp:TextBox ID="gv_txt_college" runat="server" Text='<%# Eval("college") %>' TabIndex="6">
</asp:TextBox>--%>
</td>
</tr>
</table>
</td>
<td>
</td>
</tr>
<tr>
<td align="right" colspan="2">
<asp:Button ID="btnUpdate" Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>'
runat="server" CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'>
</asp:Button>
<asp:Button ID="btnCancel" Text="Cancel" runat="server" CausesValidation="False"
CommandName="Cancel"></asp:Button>
</td>
</tr>
</table>
</FormTemplate>
</EditFormSettings>
</MasterTableView>
<ClientSettings>
<ClientEvents OnRowDblClick="RowDblClick"></ClientEvents>
</ClientSettings>
</telerik:radgrid>

ASP.net listview dropdown item getting the value from another table

I am trying to build an admin page in order to let the user create edit update the records of the specific table. "District" table has the following properties: DistrictID, DistrictName, Description, DistrictImage, CityFK. Since CityFK is just numbers which represents CityID of the table "City" and does not mean anything to the user I have used a dropdown menu instead and it displays all city names as "DataTextField" and CityIDs as "DataValueField" from the table "City". But my aim is to insert that "DataValueField" into the District table as CityFK. But whenever I enter a new District record and choose a City from the dropdown and press "Insert" button of the listview, CityFK of that regarding record is "0".
I paste the whole listview but if you look at the dropdownlist at the InsertItemTemplate or EditItemTemplate you will what I mean;
<asp:ListView ID="DistrictList" runat="server" DataKeyNames="DistrictID" InsertItemPosition="LastItem" DataSourceID="DistrictEntityDataSource" >
<AlternatingItemTemplate>
<tr style="background-color:#FFF8DC;">
<td>
<asp:Button ID="DeleteButton" runat="server" CommandName="Delete" Text="Delete" />
<asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Edit" />
</td>
<td>
<asp:Label ID="DistrictIDLabel" runat="server" Text='<%# Eval("DistrictID") %>' />
</td>
<td>
<asp:Label ID="DistrictNameLabel" runat="server" Text='<%# Eval("DistrictName") %>' />
</td>
<td>
<asp:Label ID="DescriptionLabel" runat="server" Text='<%# Eval("Description") %>' />
</td>
<td>
<asp:Image ID="DistrictImageLabel" runat="server" Height="100px" ImageUrl='<%# "~/Handlers/ImageHandler.ashx?ID="+Eval("DistrictID")+"&Entity=District"%>'/>
</td>
<td>
<asp:Label ID="CityFKLabel" runat="server" Text='<%# Eval("CityFK") %>' />
</td>
</tr>
</AlternatingItemTemplate>
<EditItemTemplate>
<tr style="background-color:#008A8C;color: #FFFFFF;">
<td>
<asp:Button ID="UpdateButton" runat="server" CommandName="Update" Text="Update" />
<asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Cancel" />
</td>
<td>
<asp:Label ID="DistrictIDLabel1" runat="server" Text='<%# Eval("DistrictID") %>' />
</td>
<td>
<asp:TextBox ID="DistrictNameTextBox" runat="server" Text='<%# Bind("DistrictName") %>' />
</td>
<td>
<asp:TextBox ID="DescriptionTextBox" runat="server" Text='<%# Bind("Description") %>' />
</td>
<td>
<asp:FileUpload ID="FileUploadDistrict2" runat="server" />
</td>
<td>
<asp:DropDownList ID="CityFKDropDownList" runat="server" AutoPostBack="true" DataSourceID="ddlCityFK_DataSource" ViewStateMode="Enabled"
DataTextField="CityName" DataValueField="CityID"
AppendDataBoundItems="true">
<asp:ListItem Text="-Stadt Wählen-" Value="0" ></asp:ListItem>
</asp:DropDownList>
<asp:EntityDataSource ID="ddlCityFK_DataSource" runat="server"
ConnectionString="name=MedicalEntities" DefaultContainerName="MedicalEntities"
EntitySetName="Cities" >
</asp:EntityDataSource>
</td>
</tr>
</EditItemTemplate>
<EmptyDataTemplate>
<table runat="server" style="background-color: #FFFFFF;border-collapse: collapse;border-color: #999999;border-style:none;border-width:1px;">
<tr>
<td>No data was returned.</td>
</tr>
</table>
</EmptyDataTemplate>
<InsertItemTemplate>
<tr style="">
<td>
<asp:Button ID="InsertButton" runat="server" CommandName="Insert" Text="Insert" />
<asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Clear" />
</td>
<td>
<asp:TextBox ID="DistrictIDTextBox" runat="server" Text='<%# Bind("DistrictID") %>' />
</td>
<td>
<asp:TextBox ID="DistrictNameTextBox" runat="server" Text='<%# Bind("DistrictName") %>' />
</td>
<td>
<asp:TextBox ID="DescriptionTextBox" runat="server" Text='<%# Bind("Description") %>' />
</td>
<td>
<asp:FileUpload ID="FileUploadDistrict" runat="server"/>
</td>
<td>
<asp:DropDownList ID="CityFKDropDownList" runat="server" AutoPostBack="true" DataSourceID="ddlCityFK_DataSource" ViewStateMode="Enabled"
DataTextField="CityName" DataValueField="CityID"
AppendDataBoundItems="true">
<asp:ListItem Text="-Stadt Wählen-" Value="0" ></asp:ListItem>
</asp:DropDownList>
<asp:EntityDataSource ID="ddlCityFK_DataSource" runat="server"
ConnectionString="name=MedicalEntities" DefaultContainerName="MedicalEntities"
EntitySetName="Cities">
</asp:EntityDataSource>
</td>
</tr>
</InsertItemTemplate>
<ItemTemplate>
<tr style="background-color:#DCDCDC;color: #000000;">
<td>
<asp:Button ID="DeleteButton" runat="server" CommandName="Delete" Text="Delete" />
<asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Edit" />
</td>
<td>
<asp:Label ID="DistrictIDLabel" runat="server" Text='<%# Eval("DistrictID") %>' />
</td>
<td>
<asp:Label ID="DistrictNameLabel" runat="server" Text='<%# Eval("DistrictName") %>' />
</td>
<td>
<asp:Label ID="DescriptionLabel" runat="server" Text='<%# Eval("Description") %>' />
</td>
<td>
<asp:Image ID="DistrictImageLabel" runat="server" Height="100px" ImageUrl='<%# "~/Handlers/ImageHandler.ashx?ID="+Eval("DistrictID")+"&Entity=District"%>'/>
</td>
<td>
<asp:Label ID="CityFKLabel" runat="server" Text='<%# Eval("CityFK") %>' />
</td>
</tr>
</ItemTemplate>
<LayoutTemplate>
<table runat="server">
<tr runat="server">
<td runat="server">
<table id="itemPlaceholderContainer" runat="server" border="1" style="background-color: #FFFFFF;border-collapse: collapse;border-color: #999999;border-style:none;border-width:1px;font-family: Verdana, Arial, Helvetica, sans-serif;">
<tr runat="server" style="background-color:#DCDCDC;color: #000000;">
<th runat="server"></th>
<th runat="server">DistrictID</th>
<th runat="server">DistrictName</th>
<th runat="server">Description</th>
<th runat="server">DistrictImage</th>
<th runat="server">CityFK</th>
</tr>
<tr id="itemPlaceholder" runat="server">
</tr>
</table>
</td>
</tr>
<tr runat="server">
<td runat="server" style="text-align: center;background-color: #CCCCCC;font-family: Verdana, Arial, Helvetica, sans-serif;color: #000000;">
<asp:DataPager ID="DataPager1" runat="server">
<Fields>
<asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True" ShowLastPageButton="True" />
</Fields>
</asp:DataPager>
</td>
</tr>
</table>
</LayoutTemplate>
<SelectedItemTemplate>
<tr style="background-color:#008A8C;font-weight: bold;color: #FFFFFF;">
<td>
<asp:Button ID="DeleteButton" runat="server" CommandName="Delete" Text="Delete" />
<asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Edit" />
</td>
<td>
<asp:Label ID="DistrictIDLabel" runat="server" Text='<%# Eval("DistrictID") %>' />
</td>
<td>
<asp:Label ID="DistrictNameLabel" runat="server" Text='<%# Eval("DistrictName") %>' />
</td>
<td>
<asp:Label ID="DescriptionLabel" runat="server" Text='<%# Eval("Description") %>' />
</td>
<td>
<asp:Image ID="DistrictImageLabel" runat="server" Height="100px" ImageUrl='<%# "~/Handlers/ImageHandler.ashx?ID="+Eval("DistrictID")+"&Entity=District"%>'/>
</td>
<td>
<asp:Label ID="CityFKLabel" runat="server" Text='<%# Eval("CityFK") %>' />
</td>
</tr>
</SelectedItemTemplate>
</asp:ListView>
<asp:EntityDataSource ID="DistrictEntityDataSource" runat="server" ConnectionString="name=MedicalEntities"
DefaultContainerName="MedicalEntities" EnableDelete="True" EnableFlattening="False" EnableInsert="True"
EnableUpdate="True" EntitySetName="Districts" Include="City" EntityTypeFilter="District">
</asp:EntityDataSource>
So I am trying to bind that dropdownlist values to the CityFK during Insert and Edit operations.
I figured it out. As workaround I added one textbox at the same column with the dropdownlist and set its visible attribute to false;
<asp:TextBox ID="CityFKTextBoxInsert" runat="server" Visible="false" Text='<%# Bind("CityFK") %>' />
In case you also encounter such a problem I add the code-behind and asp side here;
<InsertItemTemplate>
<tr style="">
<td>
<asp:Button ID="InsertButton" runat="server" CommandName="Insert" Text="Insert" />
<asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Clear" />
</td>
<td>
<asp:TextBox ID="DistrictIDTextBox" runat="server" Text='<%# Bind("DistrictID") %>' />
</td>
<td>
<asp:TextBox ID="DistrictNameTextBox" runat="server" Text='<%# Bind("DistrictName") %>' />
</td>
<td>
<asp:TextBox ID="DescriptionTextBox" runat="server" Text='<%# Bind("Description") %>' />
</td>
<td>
<asp:FileUpload ID="FileUploadDistrictInsert" runat="server" />
</td>
<td>
<asp:TextBox ID="CityFKTextBoxInsert" runat="server" Visible="false" Text='<%# Bind("CityFK") %>' />
<asp:DropDownList ID="CityFKDropDownListInsert" runat="server" AutoPostBack="true" DataSourceID="ddlCityFK_DataSource2" ViewStateMode="Enabled"
DataTextField="CityName" DataValueField="CityID" OnSelectedIndexChanged="CityFKDropDownListInsert_SelectedIndexChanged"
AppendDataBoundItems="true">
<asp:ListItem Text="-Stadt Wählen-" Value="0" ></asp:ListItem>
</asp:DropDownList>
<asp:EntityDataSource ID="ddlCityFK_DataSource2" runat="server"
ConnectionString="name=MedicalEntities" DefaultContainerName="MedicalEntities"
EntitySetName="Cities" >
</asp:EntityDataSource>
</td>
</tr>
</InsertItemTemplate>
Then I have added a "OnSelectedIndexChanged" event to the dropdown and assign the selected value to that textbox;
protected void CityFKDropDownListInsert_SelectedIndexChanged(object sender, EventArgs e)
{
DropDownList DropdownDistrict = (DropDownList)DistrictList.InsertItem.FindControl("CityFKDropDownListInsert");
TextBox DistrictTextBox = (TextBox)DistrictList.InsertItem.FindControl("CityFKTextBoxInsert");
DistrictTextBox.Text = DropdownDistrict.SelectedValue;
}
If you want to apply that solution also to EditItemTemplate only thing you have to do changing that line;
DropDownList DropdownDistrict = (DropDownList)DistrictList.InsertItem.FindControl("CityFKDropDownListInsert");
to this;
DropDownList DropdownDistrict = (DropDownList)DistrictList.EditItem.FindControl("CityFKDropDownListInsert");

place the insert part at above the table in listviews

actually i have below listview at my user control page:
and i want to replace the insert part to above the table as below:
and my listview code is as below:
<asp:ListView ID="lv_Uc_Module" runat="server"
onitemediting="lv_Uc_Module_ItemEditing"
onitemupdating="lv_Uc_Module_ItemUpdating"
onitemcanceling="lv_Uc_Module_ItemCanceling"
onitemdeleting="lv_Uc_Module_ItemDeleting"
OnItemDataBound="lv_Uc_Module_ItemDataBound"
InsertItemPosition="LastItem"
OnSorting="lv_Uc_Module_Sorting"
oniteminserting="lv_Uc_Module_ItemInserting"
DataKeyNames="EmpID">
<LayoutTemplate>
<table id="table_Lv_Layout" runat="server">
<tr id="tr_Table_Layout" runat="server">
<td id="td_Table_Layout" runat="server">
<table ID="itemPlaceholderContainer" runat="server" class="th_ItemTemplate">
<tr id="tr_Table_IphContainer" runat="server" style="">
<th id="th1_Table_IphContainer" runat="server">
<asp:Label ID="lb1_Table_IphContainer" runat="server" Text=""></asp:Label>
<asp:ImageButton ID="imb1_Table_IphContainer" CommandArgument="EmpID" CommandName="Sort" ImageUrl="~/Images/asc.png" runat="server" />
</th>
<th id="th2_Table_IphContainer" runat="server">
<asp:Label ID="lb2_Table_IphContainer" runat="server" Text=""></asp:Label>
<asp:ImageButton ID="imb2_Table_IphContainer" CommandArgument="EmpName" CommandName="Sort" ImageUrl="~/Images/asc.png" runat="server" />
</th>
<th id="th3_Table_IphContainer" runat="server">
<asp:Label ID="lb3_Table_IphContainer" runat="server" Text=""></asp:Label>
</th>
<th id="th4_Table_IphContainer" runat="server">
<asp:Label ID="lb4_Table_IphContainer" runat="server" Text=""></asp:Label>
</th>
<th id="th5_Table_IphContainer" runat="server">
<asp:Label ID="lb5_Table_IphContainer" runat="server" Text=""></asp:Label>
</th>
<th id="th6_Table_IphContainer" runat="server">
</th>
</tr>
<tr ID="itemPlaceholder" runat="server">
</tr>
</table>
</td>
</tr>
<tr id="tr_Validate_Table_Layout" runat="server">
<td id="td_Validate_Table_Layout" runat="server" style="text-align: center;background-color: #CCCCCC;">
<asp:ValidationSummary ID="ValidationSummary1" runat="server" HeaderText="You received the following errors:" ShowMessageBox="true" ShowSummary="false" ValidationGroup="VGEditTmp" />
<asp:ValidationSummary ID="ValidationSummary2" runat="server" HeaderText="You received the following errors:" ShowMessageBox="true" ShowSummary="false" ValidationGroup="VGInsertTmp" />
</td>
</tr>
</table>
<br />
<asp:DataPager ID="lv_DataPager" runat="server" PagedControlID="lv_Uc_Module" PageSize="5" OnPreRender="lv_DataPager_PreRender">
<Fields>
<asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="true" ShowLastPageButton="true" />
<asp:TemplatePagerField>
<PagerTemplate>
<span style="color:Maroon;">Records:
<%# Container.StartRowIndex >= 0 ? (Container.StartRowIndex + 1) : 0 %>
-
<%# (Container.StartRowIndex + Container.PageSize) > Container.TotalRowCount ? Container.TotalRowCount : (Container.StartRowIndex + Container.PageSize)%>
of
<%# Container.TotalRowCount %>
<span style="color:Red;">
OR
</span>
<span style="color: Blue;">
Page
<%# Container.TotalRowCount>0 ? (Container.StartRowIndex / Container.PageSize) + 1 : 0 %>
of
<%# Math.Ceiling((double)Container.TotalRowCount / Container.PageSize) %>
</span>
</span>
</PagerTemplate>
</asp:TemplatePagerField>
</Fields>
</asp:DataPager>
</LayoutTemplate>
<ItemTemplate>
<tr class="tr_ItemTemplate">
<td>
<asp:Label ID="lb_ItemTemp1" runat="server" Text='' />
</td>
<td>
<asp:Label ID="lb_ItemTemp2" runat="server" Text='' />
</td>
<td>
<asp:Label ID="lb_ItemTemp3" runat="server" Text='' />
</td>
<td>
<asp:Label ID="lb_ItemTemp4" runat="server" Text='' />
</td>
<td>
<asp:Label ID="lb_ItemTemp5" runat="server" Text='' />
</td>
<td>
<asp:Button ID="btn_Edit" runat="server" CommandName="Edit" Text="" CssClass="btn_Edit" CausesValidation="True" />
<asp:Button ID="btn_Delete" runat="server" CommandName="Delete" Text="" CssClass="btn_Delete" CausesValidation="false" OnClientClick="return confirm('Are you sure you want to delete this item?');" />
</td>
</tr>
</ItemTemplate>
<EditItemTemplate>
<tr style="background-color:#008A8C;color: #FFFFFF;">
<td>
<asp:Label ID="lb_ItemTemp1" runat="server" Text='' />
</td>
<td>
<asp:TextBox ID="td_EditTemp1" runat="server" Text='' ValidationGroup="VGEditTmp" />
<asp:RequiredFieldValidator runat="server" ID="RequiredName" ControlToValidate="td_EditTemp1" ErrorMessage="Name is required" ValidationGroup="VGEditTmp" Display="None" ></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="regName" runat="server" ControlToValidate="td_EditTemp1" ValidationExpression="^[a-zA-Z'.\s]{1,50}" ErrorMessage="Enter a valid Name" ValidationGroup="VGEditTmp" Display="None"></asp:RegularExpressionValidator>
</td>
<td>
<asp:TextBox ID="td_EditTemp2" runat="server" Text='' />
</td>
<td>
<asp:TextBox ID="td_EditTemp3" runat="server" Text='' ValidationGroup="VGEditTmp" />
<asp:RangeValidator ID="ValidateAge" runat="server" ControlToValidate="td_EditTemp3" MinimumValue="18" MaximumValue="50" Type="Integer" ErrorMessage="Age should be within the valid interval(18-50)!" ValidationGroup="VGEditTmp" SetFocusOnError="true" Display="None"></asp:RangeValidator>
</td>
<td>
<asp:TextBox ID="td_EditTemp4" runat="server" Text='' />
</td>
<td>
<asp:Button ID="btn_Update" runat="server" CommandName="Update" Text="Update" ValidationGroup="VGEditTmp" />
<asp:Button ID="btn_Cancel" runat="server" CommandName="Cancel" Text="Cancel" CausesValidation="false" />
</td>
</tr>
</EditItemTemplate>
<InsertItemTemplate>
<tr style="background-color:#008A8C;font-weight: bold;color: #FFFFFF;">
<td>
</td>
<td>
<asp:TextBox ID="td_EditTemp1" runat="server" Text='' ValidationGroup="VGInsertTmp" />
<asp:RequiredFieldValidator runat="server" ID="RequiredName" ControlToValidate="td_EditTemp1" ErrorMessage="Name is required" ValidationGroup="VGInsertTmp" Display="None"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="regName" runat="server" ControlToValidate="td_EditTemp1" ValidationExpression="^[a-zA-Z'.\s]{1,50}" ErrorMessage="Enter a valid Name" ValidationGroup="VGInsertTmp" Display="None"></asp:RegularExpressionValidator>
</td>
<td>
<asp:TextBox ID="td_EditTemp2" runat="server" Text='' />
</td>
<td>
<asp:TextBox ID="td_EditTemp3" runat="server" Text='' ValidationGroup="VGInsertTmp" />
<asp:RangeValidator ID="ValidateAge" runat="server" ControlToValidate="td_EditTemp3" MinimumValue="18" MaximumValue="50" Type="Integer" ErrorMessage="Age should be within the valid interval(18-50)!" ValidationGroup="VGInsertTmp" SetFocusOnError="true" Display="None"></asp:RangeValidator>
</td>
<td>
<asp:TextBox ID="td_EditTemp4" runat="server" Text='' />
</td>
<td>
<asp:Button ID="btn_Insert" runat="server" CommandName="Insert" Text="Insert" ValidationGroup="VGInsertTmp" />
<asp:Button ID="btn_Cancel" runat="server" CommandName="Cancel" Text="Clear" CausesValidation="false" />
</td>
</tr>
</InsertItemTemplate>
</asp:ListView>
could you please guide me how to overcome this problem. i'm using asp.net and c#.
Appreciate your consideration.
I think you need to change your GridView's InsertItemPosition property from InsertItemPosition="LastItem"
to
InsertItemPosition="FirstItem"
in your declaration.

modal popup extender problem

i use modal popup extender to show my details in another separate window it is a panel contains some controls the problem is ::
when i click on my button which contains::
the Show() method the parent page just frozen and no popup appears at all on the other side i have a grid view when i click on the last button on it the popup appears where the other buttons on the grid view make the same behavior of my first button , i donot know what is the problem my panel visibility = true and no setting in my behind code..i view the source and i find the panel with its contents then why the popup window doesnot appear..i search alot but i donot find a solution to my problem ..
my aspx::
<asp:Panel id="master_editMode" runat="server" >
<div id="masterDiv" style="width:98%" dir="rtl">
<div id="masterControls" align="center">
<table border="0" width="98%">
<tr>
<td align="center" dir="rtl">
<asp:ObjectDataSource ID="ObjDS_AllTasks" runat="server"
SelectMethod="Get_All_Tasks" TypeName="DocumentFlowModuleDTO.TaskDTO">
</asp:ObjectDataSource>
<asp:HiddenField ID="hd_Task_Code" runat="server" />
<table>
<tr>
<td>
<asp:Label ID="Label11" runat="server" Text="Search for Task" Visible="False"></asp:Label>
</td>
<td align="right">
<asp:TextBox ID="txt_Search" runat="server" AutoPostBack="True"
ontextchanged="txt_Search_TextChanged" Width="200px" Visible="False"></asp:TextBox>
</td>
<td>
</td>
</tr>
<tr>
<td colspan="3">
<asp:GridView ID="grd_AllTasks" runat="server" AllowPaging="True"
AutoGenerateColumns="False" CssClass="Alternating" DataKeyNames="task_code"
DataSourceID="ObjDS_AllTasks"
onpageindexchanging="grd_AllTasks_PageIndexChanging"
onrowdatabound="grd_AllTasks_RowDataBound" style="margin-right: 0px">
<RowStyle VerticalAlign="Top" />
HeaderText="ÍÐÝ">
<ItemTemplate>
<asp:ImageButton ID="btn_Delete_Task" runat="server"
CommandArgument="<%# Bind('task_code') %>" Height="33px"
ImageUrl="~/Images/delete.png" oncommand="btn_Delete_Task_Command"
Width="67px" />
<cc1:ConfirmButtonExtender ID="btn_Delete_Task_ConfirmButtonExtender"
runat="server" ConfirmText="åá ÊÑíÏ ÍÐÝ æËíÞÉ ÇáÇÚÊãÇÏ ¿" Enabled="True"
TargetControlID="btn_Delete_Task">
</cc1:ConfirmButtonExtender>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<HeaderStyle HorizontalAlign="Right" />
</asp:GridView>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="right" dir="rtl">
<asp:Label ID="lbl_TaskName" runat="server" Font-Bold="True" Font-Size="13pt"></asp:Label>
</td>
</tr>
<tr>
<td align="center" dir="rtl" style="height: 196px">
<table>
<tr>
<td align="left">
<asp:Label ID="lbl_No_States" runat="server" Font-Bold="True" ForeColor="Red"></asp:Label>
</td>
<td align="right">
<asp:ImageButton ID="btn_AddStatesToTask" runat="server"
ImageUrl="Images/add.png" onclick="btn_AddStatesToTask_Click" Visible="False" />
<asp:Button ID="Dummy_btn2" runat="server" Text="Button" Style="display:none;" />
<cc1:ModalPopupExtender ID="btn_AddStatesToTask_ModalPopupExtender"
runat="server"
TargetControlID="Dummy_btn2"
BackgroundCssClass="modalBackground"
PopupControlID="pnl_Add_States"
DropShadow="True">
</cc1:ModalPopupExtender>
</td>
</tr>
</table>
<asp:HiddenField ID="hd_StateSerial" runat="server" />
<asp:HiddenField ID="hd_StateRowIndex" runat="server" />
<asp:GridView ID="grd_States" runat="server" AllowPaging="True" DataKeyNames="state_serial"
onpageindexchanging="grd_States_PageIndexChanging" Visible="False"
CssClass="Alternating" AutoGenerateColumns="False">
<Columns>
<asp:BoundField DataField="state_name" HeaderText="ÇáãÑÍáÉ"
ShowHeader="False" />
<asp:BoundField DataField="state_order" HeaderText="ÊÑÊíÈ ÇáãÑÍáÉ"
ShowHeader="False" />
<asp:TemplateField HeaderText="Power" ShowHeader="False">
<EditItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server" />
</EditItemTemplate>
<ItemTemplate>
<asp:CheckBox ID="chb_StatePower" runat="server"
Checked='<%# Convert.ToBoolean(Eval("power_flag")) %>' Enabled="False" />
</ItemTemplate>
<ItemStyle Width="40px" />
</asp:TemplateField>
<asp:TemplateField HeaderText="New" ShowHeader="False">
<EditItemTemplate>
<asp:CheckBox ID="CheckBox3" runat="server" />
<asp:Button ID="Dummy_btn4" runat="server" Text="Button" Style="display:none;" />
<cc1:ModalPopupExtender ID="btn_TaskState_Edit_ModalPopupExtender" runat="server"
TargetControlID="Dummy_btn4"
BackgroundCssClass="modalBackground"
PopupControlID="pnl_Add_States"
DropShadow="True">
</cc1:ModalPopupExtender>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="ÍÐÝ" ShowHeader="False">
<ItemTemplate>
<asp:ImageButton ID="btn_TaskState_Delete" runat="server"
CommandArgument="<%# Bind('state_serial') %>" Height="26px"
ImageUrl="~/Images/delete.png" oncommand="btn_TaskState_Delete_Command"
Width="47px" />
<cc1:ConfirmButtonExtender ID="btn_TaskState_Delete_ConfirmButtonExtender"
runat="server" ConfirmText="åá ÊÑíÏ ÍÐÝ ÇáãÑÍáÉ ¿" Enabled="True"
TargetControlID="btn_TaskState_Delete">
</cc1:ConfirmButtonExtender>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</td>
</tr>
<tr>
<td>
<asp:ObjectDataSource ID="ObjectDataSource_States" runat="server"
SelectMethod="Select_TaskStates" TypeName="DocumentFlowModule.DTO.TaskStateDTO">
<SelectParameters>
<asp:Parameter Name="task_code" Type="Int32" />
</SelectParameters>
</asp:ObjectDataSource>
</td>
</tr>
</table>
</div>
</div>
</asp:Panel>
<asp:Panel ID="pnl_Add_Task" runat="server" CssClass="modalPopup"><%-- Style="display:none;"--%>
<div id="div3" style="width: 95%">
<div id="div4" align="center">
<table>
<tr>
<td>
<asp:UpdatePanel ID="UpPnl1" runat="server">
<ContentTemplate>
<table dir="rtl" style="text-align: right">
<tr bgcolor="#f1ece2">
<th align="right" height="35" valign="middle" colspan="3">
<asp:Label ID="lbl_New_Task" runat="server" Font-Bold="False" Font-Size="14pt"
Text="ÅÖÇÝÉ æËíÞÉ ÇÚÊãÇÏ" Visible="False"></asp:Label>
<asp:Label ID="lbl_Edit_Task" runat="server" Font-Bold="False" Font-Size="14pt"
Text="ÊÚÏíá æËíÞÉ ÇÚÊãÇÏ" Visible="False"></asp:Label>
</th>
</tr>
<tr>
<td class="title" width="160">
<asp:Label ID="Label1" runat="server" Text="Task Name"></asp:Label>
</td>
<td style="width: 140px">
<asp:TextBox ID="txt_TaskName" runat="server"></asp:TextBox>
</td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="txt_TaskName" ErrorMessage="*" ValidationGroup="G1"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="title" width="160">
<asp:Label ID="Label10" runat="server" Text="DataBase Name"></asp:Label>
</td>
<td style="width: 140px">
<asp:DropDownList ID="ddl_DataBases" runat="server" AutoPostBack="True"
ondatabound="ddl_DataBases_DataBound"
onselectedindexchanged="ddl_DataBases_SelectedIndexChanged">
</asp:DropDownList>
</td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server"
ControlToValidate="ddl_DataBases" ErrorMessage="*" InitialValue="--Select--"
ValidationGroup="G1"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="title" width="160">
<asp:Label ID="Label2" runat="server" Text="Table Name"></asp:Label>
</td>
<td style="width: 140px">
<asp:DropDownList ID="ddl_Tables" runat="server" AutoPostBack="True"
ondatabound="ddl_Tables_DataBound"
onselectedindexchanged="ddl_Tables_SelectedIndexChanged">
</asp:DropDownList>
</td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server"
ControlToValidate="ddl_Tables" ErrorMessage="*" InitialValue="--Select--"
ValidationGroup="G1"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="title" width="160">
<asp:Label ID="Label17" runat="server" Text="Table Key"></asp:Label>
</td>
<td style="width: 140px">
<asp:Label ID="lbl_Key" runat="server"></asp:Label>
<asp:CheckBoxList ID="cbl_Columns" runat="server">
</asp:CheckBoxList>
</td>
<td>
<asp:Label ID="lbl_Select_Key" runat="server" ForeColor="Red"></asp:Label>
</td>
</tr>
<tr>
<td class="title" width="160">
<asp:Label ID="Label18" runat="server" Text="Current Record State"></asp:Label>
</td>
<td style="width: 140px">
<asp:DropDownList ID="ddl_Columns" runat="server" AutoPostBack="True"
ondatabound="ddl_Columns_DataBound">
</asp:DropDownList>
</td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server"
ControlToValidate="ddl_Columns" ErrorMessage="*" InitialValue="--Select--"
ValidationGroup="G1"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="title" width="160">
<asp:Label ID="Label5" runat="server" Text="Form View "></asp:Label>
</td>
<td style="width: 140px">
<asp:TextBox ID="txt_F_View" runat="server"></asp:TextBox>
</td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server"
ControlToValidate="txt_F_View" ErrorMessage="*" InitialValue="--Select--"
ValidationGroup="G1"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="title" width="160">
<asp:Label ID="Label6" runat="server" Text="Form New"></asp:Label>
</td>
</td>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>
</td>
</tr>
<tr>
<td dir="rtl" align="center">
<asp:ImageButton ID="btn_OK" runat="server" ImageUrl="~/Images/add.png"
onclick="btn_OK_Click" ValidationGroup="G1" Visible="False" />
<asp:ImageButton ID="btn_Edit" runat="server" ImageUrl="~/Images/edit.png"
onclick="btn_Edit_Click" ValidationGroup="G1" Visible="False" />
<asp:ImageButton ID="btn_Cancel_Task" runat="server" CausesValidation="False"
Height="36px" ImageUrl="~/Images/cancel.png" onclick="btn_Cancel_Task_Click" />
</td>
</tr>
</table>
</div>
</div>
</asp:Panel>
the btn_add _task does not make my popup appear just freeze the parent page
my .cs
protected void btn_Add_Task_Click(object sender, EventArgs e)
{
//AjaxControlToolkit.ModalPopupExtender modal1 = (AjaxControlToolkit.ModalPopupExtender) table1.FindControl("btn_Add_Task_ModalPopupExtender");
//modal1.Show();
grd_States.Visible = false;
lbl_No_States.Text = "";
btn_AddStatesToTask.Visible = false;
lbl_TaskName.Text = "";
//master_editMode.Visible = true;
//pnl_Add_Task.Visible = true;
btn_OK.Visible = true;
btn_Edit.Visible = false;
lbl_New_Task.Visible = true;
lbl_Edit_Task.Visible = false;
txt_TaskName.Text = "";
ddl_DataBases.ClearSelection();
ddl_Tables.Items.Clear();
ddl_Columns.Items.Clear();
cbl_Columns.Items.Clear();
txt_F_New.Text = "";
txt_F_View.Text = "";
txt_Params.Text = "";
txt_SP_Name.Text = "";
btn_Add_Task_ModalPopupExtender.Show();
}
thanks in advance
EDITED::
<table align="center" dir="rtl">
<tr>
<td >
<asp:Button ID="Dummy_btn" runat="server" Text="Button" Style="display:none;" />
<asp:Button ID="btn_Add_Task" runat="server" Text="ÅÖÇÝÉ æËíÞÉ ÇÚÊãÇÏ ÌÏíÏÉ"
onclick="btn_Add_Task_Click" Font-Bold="True" Font-Size="12pt"
ForeColor="#0066FF" />
<cc1:ModalPopupExtender ID="btn_Add_Task_ModalPopupExtender" runat="server"
TargetControlID="Dummy_btn"
PopupControlID="pnl_Add_Task"
BackgroundCssClass="modalBackground"
DropShadow="True" >
</cc1:ModalPopupExtender>
</td>
</tr>
</table>`
If you want your modal popup to be displayed when the user clicks on the btn_Add_Task button, you should set that button as the TargetControlID of the extender:
<cc1:ModalPopupExtender ID="btn_Add_Task_ModalPopupExtender" runat="server"
TargetControlID="btn_Add_Task" PopupControlID="pnl_Add_Task"
BackgroundCssClass="modalBackground" DropShadow="True" />
In your current code, the modal popup is triggered by a button named Dummy_btn, which I can't find in your markup, but which probably isn't what you want.
We had many issues with ajax popup. you might want to try the approach we have been using for past one month or so with out any issues. This approach creates a popup with out need of ajax / jquery / javascript /css/ update panel .
here:
A modal popup with out using ajax, update panel, jquery or javascript- surprisingly this seems to work

Categories

Resources