paging in gridview get same data for all pages - c#

I had gridview which get data from database according to two event .The first from method ,the second when selected ddl.it worked well ,I made paging and when I go through paging pages I must click two click on number of page to go to this page also all pages get same data for firt page .So plaes any one help me.
<aspx>
<div class="div_open_CS m10 ad_mun_font">
<table width="560" border="0" align="center" cellpadding="2" cellspacing="0">
<tr>
<td class="pag_bor">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="Pag_toparow">
</td>
<td class="Pag_hedfont">
Dealers list
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="pag_bor">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="ad_mun_font_h" width="100">
Select City
</td>
<td>
<asp:SqlDataSource ID="SDSGetDealerArea" runat="server" ConnectionString="<%$ ConnectionStrings:ElarabyGroup %>"
ProviderName="System.Data.SqlClient" SelectCommand="SELECT [AREA_ID], [AREA_ENG] FROM [DealerArea]">
</asp:SqlDataSource>
<%-- <asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>--%>
<asp:DropDownList CssClass="ad_mun_font_h" ID="DDlCity" runat="server" AutoPostBack="True"
DataSourceID="SDSGetDealerArea" DataTextField="AREA_ENG" DataValueField="AREA_ID"
OnDataBound="DDlCity_DataBound" OnSelectedIndexChanged="DDlCity_SelectedIndexChanged">
</asp:DropDownList>
<%-- </ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="DDlCity" EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>--%>
</td>
<td>
<asp:Label ID="LblResult" runat="server" Text="Result" Font-Bold="True" ForeColor="#006699"
Visible="false"></asp:Label>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td valign="top" class="tm10 rm10">
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"
AutoGenerateColumns="False" BackColor="White" BorderColor="#999999" BorderStyle="None"
CellPadding="3" DataKeyNames="DEALER_ID,LOC_ID,CAT_ID,AREA_ID" CellSpacing="3"
GridLines="Horizontal" Width="510px" BorderWidth="1px" OnPageIndexChanging="GridView1_PageIndexChanging">
<FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
<RowStyle BackColor="#EEEEEE" ForeColor="Black" />
<Columns>
<asp:TemplateField HeaderText="Name" SortExpression="NAME_ENG">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("NAME_ENG") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("NAME_ENG") %>'></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Address" SortExpression="ADR_ENG">
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("ADR_ENG") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("ADR_ENG") %>'></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Telephone" SortExpression="TEL_ENG">
<ItemTemplate>
<asp:Label ID="Label3" runat="server" Text='<%# Bind("TEL_ENG") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("TEL_ENG") %>'></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Mobile" SortExpression="TEL_ARA">
<ItemTemplate>
<asp:Label ID="Label4" runat="server" Text='<%# Bind("TEL_ARA") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("TEL_ARA") %>'></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Location" SortExpression="LOC_ENG">
<ItemTemplate>
<asp:Label ID="Label5" runat="server" Text='<%# Bind("LOC_ENG") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="TextBox5" runat="server" Text='<%# Bind("LOC_ENG") %>'></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Category" SortExpression="CAT_NAME">
<ItemTemplate>
<asp:Label ID="Label6" runat="server" Text='<%# Bind("CAT_NAME") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="TextBox6" runat="server" Text='<%# Bind("CAT_NAME") %>'></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Area" SortExpression="AREA_ENG">
<ItemTemplate>
<asp:Label ID="Label7" runat="server" Text='<%# Bind("AREA_ENG") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="TextBox7" runat="server" Text='<%# Bind("AREA_ENG") %>'></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
</Columns>
<PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="#DCDCDC" />
</asp:GridView>
<asp:Panel ID="pnlModal" runat="server" Style="display: none" CssClass="modalPopup">
Our Valued Customer You Are Not Registered Are You Want To Register?
<br />
<br />
<br />
<br />
<table id="LoginTL" runat="server" width="300" border="0" align="center" cellpadding="0"
cellspacing="2" visible="true" style="border-color: #666666">
<tr>
<td width="80px" class="bod_d_reg_txt_p lm7">
Username :
</td>
<td>
<label>
<asp:TextBox ID="TxtUser" runat="server" Width="125px"></asp:TextBox>
</label>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="*"
ControlToValidate="TxtUser" Display="Dynamic" SetFocusOnError="True">*</asp:RequiredFieldValidator>
</td>
<td>
<table width="110" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<label>
<asp:CheckBox ID="CBRemeber" runat="server" class="tx_s" OnCheckedChanged="CBRemeber_CheckedChanged" />
</label>
</td>
<td class="bod_d_reg_txt_w">
Remember me
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="80" class="bod_d_reg_txt_p lm7">
Password :
</td>
<td>
<label>
<asp:TextBox ID="TXTPassword" runat="server" TextMode="Password" Width="125px"></asp:TextBox>
</label>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="*"
ControlToValidate="TXTPassword" Display="Dynamic" SetFocusOnError="True">*</asp:RequiredFieldValidator>
</td>
<td>
<asp:ImageButton ID="IBLogin" runat="server" ImageUrl="images/home-d_login.jpg" OnClick="IBLogin_Click" />
</td>
</tr>
<tr>
<td>
</td>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label8" runat="server" CssClass="ad_mun_font" Text="result" Visible="false"></asp:Label>
</td>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td>
Close
</td>
<td>
</td>
<td>
Register
</td>
</tr>
</table>
<br />
</asp:Panel>
<cc1:ModalPopupExtender TargetControlID="btnYes" ID="pnlModal_ModalPopupExtender"
runat="server" Enabled="True" BackgroundCssClass="modalBackground" PopupControlID="pnlModal"
CancelControlID="btnYes" DropShadow="true">
</cc1:ModalPopupExtender>
<asp:HiddenField ID="btnYes" runat="server" />
</td>
</tr>
</table>
</div>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindGridFunction();
}
}
private void BindGridFunction()
{
DataTable DT = new DataTable();
using (SqlConnection con = Connection.GetConnection())
{
SqlCommand Com = new SqlCommand();
if (DDlCity.SelectedIndex < 0)
{
Com = new SqlCommand("GetDealers", con);
Com.CommandType = CommandType.StoredProcedure;
SqlDataAdapter DA = new SqlDataAdapter(Com);
DA.Fill(DT);
GridView1.DataSource = DT;
GridView1.DataBind();
}
else
{
Com = new SqlCommand("GetDealersByArea", con);
Com.CommandType = CommandType.StoredProcedure;
Com.Parameters.Add(Parameter.NewNVarChar("#AREA_ENG", DDlCity.SelectedItem.Text));
SqlDataAdapter DA = new SqlDataAdapter(Com);
DA.Fill(DT);
GridView1.DataSource = DT;
GridView1.DataBind();
}
}
}
protected void DDlCity_SelectedIndexChanged(object sender, EventArgs e)
{
BindGridFunction();
}
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
}
}

Try rebinding after GridView1.PageIndex = e.NewPageIndex; call GridView1.DataBind();
.
--EDIT--
DataSet and then DataBind(), try it like:
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
BindGridFunction();
}

Related

how to get selected value of dropdownlist on nested gridview row command

how can i get selected value of dropdownlist on nested gridview row command.
I have a nested gridview in my page, inside of second gridview i want to use a drop down list for Driver. I am trying to get the selected value for that drop down list but unable to got it in gridview rowcommand. i try button click event also but i am unable to got it.
<asp:GridView ID="dtgNewTrips" runat="server" AllowPaging="true" AutoGenerateColumns="false" CssClass="table table-striped table-bordered table-hover" OnRowDataBound="dtgNewTrips_RowDataBound" DataKeyNames="Trips_ID">
<Columns>
<asp:TemplateField ItemStyle-Width="20px">
<ItemTemplate>
<a href="JavaScript:ViewDetails('div<%# Eval(" Trips_ID ") %>');">
<img alt="City" id="imgdiv<%# Eval("Trips_ID") %>" src="Images/Icons/plusicon.png" />
</a>
<div id="div<%# Eval(" Trips_ID ") %>" style="display: none;">
<asp:GridView ID="dtgViewDetails" runat="server" AutoGenerateColumns="false" DataKeyNames="Trips_ID" CssClass="ChildGrid" ShowHeader="false" OnRowDataBound="dtgViewDetails_RowDataBound" OnRowCommand="dtgViewDetails_RowCommand">
<Columns>
<asp:TemplateField ShowHeader="false">
<ItemTemplate>
<div>
<table style="width: 100%;">
<tr>
<td>Adults:
<asp:Label ID="lblTrip_ID" runat="server" Text='<%#Eval("Trips_ID") %>' Visible="false"></asp:Label>
<asp:Label ID="Label1" runat="server" Text='<%#Eval("AdultsCount") %>'></asp:Label>
</td>
<td>Children:
<asp:Label ID="Label2" runat="server" Text='<%#Eval("ChildrensCount") %>'></asp:Label>
</td>
<td>Passenger Comments:
<asp:Label ID="Label4" runat="server" Text='<%#Eval("PassengerComments") %>'></asp:Label>
</td>
</tr>
<tr>
<td>Trip Stops:</td>
<td>
<asp:Label ID="Label3" runat="server" Text='<%#Eval("TripStops") %>'></asp:Label>
</td>
<td>TripStops Comments:
<asp:Label ID="Label5" runat="server" Text='<%#Eval("TripStopsComments") %>'></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:DropDownList ID="ddlDriver" runat="server" DataTextField="DriverName" DataValueField="DriversInfo_ID" CssClass="form-control" AutoPostBack="false"></asp:DropDownList>
</ContentTemplate>
</asp:UpdatePanel>
</td>
<td>
<asp:Button ID="btnAssign" runat="server" Text="Assign To Driver" CssClass="btn btn-primary" CommandArgument='<%# ((GridViewRow)Container).RowIndex %>' CommandName="Assign" />
</td>
<td>
<asp:Button ID="btnAssignToAll" runat="server" OnClick="btnAssignToAll_Click" Text="Notify All Drivers" CssClass="btn btn-primary" />
<asp:Button ID="btnCancelTrip" runat="server" OnClick="btnCancelTrip_Click" Text="Cancel Trip" CssClass="btn btn-warning" />
</td>
</tr>
</table>
</div>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Trip No">
<ItemTemplate>
<asp:Label ID="lblTripRefID" runat="server" Text='<%#Eval("TripRefID") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Customer Name">
<ItemTemplate>
<asp:Label ID="lblCompanyName" runat="server" Text='<%#Eval("CompanyName") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Pickup Location">
<ItemTemplate>
<asp:Label ID="lblPickupLocation" runat="server" Text='<%#Eval("PickupLocation") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
C# Code
protected void dtgViewDetails_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Assign")
{
int rowIndex = Convert.ToInt32(e.CommandArgument);
GridView grid = (GridView)sender;
if (grid.ID == "dtgViewDetails")
{
Label lblTrip_ID = (Label)grid.Rows[rowIndex].FindControl("lblTrip_ID");
DropDownList ddlDriver = (DropDownList)grid.Rows[rowIndex].FindControl("ddlDriver");
}
}
}
But i get the by default of dropdownlist that zeroth index value.
please help me..
thanks in advance..

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

ImageButton in GridView TemplateField wont show AJAX Popup Modal

I have a page that displays a GridView containing an ImageButton TemplateField. My goal is to display an AJAX modal popup when one of those buttons are clicked, along with displaying the row where the button is pressed. The problem is that when I click on a button, it does not show the modal popup. I tried to use this tutorial and read several articles on this site about this issue but to no avail. How to properly fire the button event and show the popup?
Here is the snippet for the gridview:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
Width="505px" DataSourceID="SqlDataSource1">
<Columns>
<asp:BoundField DataField="ItemDesc"
SortExpression="ItemDesc" ItemStyle-Width="100px" ItemStyle-Height="100px">
<ItemStyle Height="100px" Width="100px"></ItemStyle>
</asp:BoundField>
<asp:BoundField DataField="Price" SortExpression="Price"
ItemStyle-Width="100px" ItemStyle-Height="100px">
<ItemStyle Height="100px" Width="100px"></ItemStyle>
</asp:BoundField>
<asp:TemplateField>
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Image ID="Image1" runat="server" Height="200px"
ImageUrl='<%# Eval("ImagePath") %>' Width="200px" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField ShowHeader="False">
<ItemTemplate>
<asp:ImageButton ID="ImageButton1" runat="server" CommandName="atc" ImageUrl="~/App_Themes/img/shop/addtocart.png"
Text="Add to Cart" CommandArgument="<%# ((GridViewRow) Container).RowIndex %>"/>
</ItemTemplate>
<ControlStyle Height="30px" Width="105px" />
<ItemStyle Width="105px" />
</asp:TemplateField>
</Columns>
</asp:GridView>
...
<asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="HiddenField1" PopupControlID="Panel1" BackgroundCssClass="modalBg" CancelControlID="btnClose">
</asp:ModalPopupExtender>
<asp:HiddenField ID="HiddenField1" runat="server" />
<asp:Panel ID="Panel1" runat="server" Width="500" Height="500" Visible="False"
style="background-color:#6f95f4; color:#000000;">
<div class="style1">
<br />
<br />
<br />
<br />
<br />
<table style="width: 90%; height: 71px;">
<tr>
<td>
Item Name</td>
<td>
<asp:Label ID="lblItemName" runat="server" Text="Label"></asp:Label>
</td>
</tr>
<tr>
<td>
Price</td>
<td>
<asp:Label ID="lblPrice" runat="server" Text="Label"></asp:Label>
</td>
</tr>
<tr>
<td colspan="2">
</td>
</tr>
<tr>
<td>
Quantity</td>
<td>
<asp:TextBox ID="TextBox2" runat="server" Type="Number" Min="1" MaxLength="100"
Width="75px" Height="23px"></asp:TextBox>
</td>
</tr>
<tr>
<td>
Total Price</td>
<td>
<asp:Label ID="lblTotalPrice" runat="server" Text="Label"></asp:Label>
</td>
</tr>
</table>
<br />
<br />
<asp:Button ID="btnAddToCart" runat="server" Text="Add to Cart"
onclick="btnAddToCart_Click" />
<br />
<br />
<asp:Button ID="btnClose" runat="server" onclick="btnClose_Click" Text="Close"
Width="199px" />
</div>
</asp:Panel>
And here's my code for the event:
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName.Equals("atc"))
{
ModalPopupExtender1.Show();
//// Retrieve the row index stored in the
//// CommandArgument property.
int index = Convert.ToInt32(e.CommandArgument);
//// Retrieve the row that contains the button
//// from the Rows collection.
GridViewRow row = GridView1.Rows[index];
lblItemName.Text = row.Cells[0].Text;
lblPrice.Text = row.Cells[1].Text;
Response.Write("<script>alert('" + row.Cells[0].Text + "\n" + row.Cells[1].Text + "');</script>");
//// Add code here to add the item to the shopping cart.
}
}
EDIT: Added the panel code.
Try like this:
100% working and Tested
Use onrowcommand="GridView1_RowCommand" for GridView
Use display:none for Your Panel instead of Visible="false"
I Commented your alert(in rowbound) it contains js error
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" Width="505px"
onrowcommand="GridView1_RowCommand"
>
<Columns>
<asp:BoundField DataField="ItemDesc" SortExpression="ItemDesc" ItemStyle-Width="100px"
ItemStyle-Height="100px">
<ItemStyle Height="100px" Width="100px"></ItemStyle>
</asp:BoundField>
<asp:BoundField DataField="Price" SortExpression="Price" ItemStyle-Width="100px"
ItemStyle-Height="100px">
<ItemStyle Height="100px" Width="100px"></ItemStyle>
</asp:BoundField>
<asp:TemplateField>
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Image ID="Image1" runat="server" Height="200px" ImageUrl='<%# Eval("ImagePath") %>'
Width="200px" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField ShowHeader="False">
<ItemTemplate>
<asp:ImageButton ID="ImageButton1" runat="server" CommandName="atc"
CausesValidation="false"
Text="Add to Cart" CommandArgument="<%# ((GridViewRow) Container).RowIndex %>" />
</ItemTemplate>
<ControlStyle Height="30px" Width="105px" />
<ItemStyle Width="105px" />
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
<ajax:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="Panel1"
PopupControlID="Panel1" OnOkScript="okClick();"
OnCancelScript="cancelClick();"
OkControlID="btnAddToCart" CancelControlID="btnClose">
</ajax:ModalPopupExtender>
<asp:HiddenField ID="HiddenField1" runat="server" />
<asp:Panel ID="Panel1" runat="server" Width="500" Height="500"
style="background-color:#6f95f4; color:#000000;display:none">
<div class="style1">
<br />
<br />
<br />
<br />
<br />
<table style="width: 90%; height: 71px;">
<tr>
<td>
Item Name</td>
<td>
<asp:Label ID="lblItemName" runat="server" Text="Label"></asp:Label>
</td>
</tr>
<tr>
<td>
Price</td>
<td>
<asp:Label ID="lblPrice" runat="server" Text="Label"></asp:Label>
</td>
</tr>
<tr>
<td colspan="2">
</td>
</tr>
<tr>
<td>
Quantity</td>
<td>
<asp:TextBox ID="TextBox2" runat="server" Type="Number" Min="1" MaxLength="100"
Width="75px" Height="23px"></asp:TextBox>
</td>
</tr>
<tr>
<td>
Total Price</td>
<td>
<asp:Label ID="lblTotalPrice" runat="server" Text="Label"></asp:Label>
</td>
</tr>
</table>
<br />
<br />
<asp:Button ID="btnAddToCart" runat="server" Text="Add to Cart"
onclick="btnAddToCart_Click" />
<br />
<br />
<asp:Button ID="btnClose" runat="server" onclick="btnClose_Click" Text="Close"
Width="199px" />
</div>
</asp:Panel>
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName.Equals("atc"))
{
ModalPopupExtender1.Show();
int index = Convert.ToInt32(e.CommandArgument);
GridViewRow row = GridView1.Rows[index];
ImageButton ImageButton1=(ImageButton)row.FindControl("ImageButton1");
// Response.Write("<script>alert('" + row.Cells[0].Text + "\n" + row.Cells[1].Text + "');</script>"); comment this
}
You didn't set OnRowCommand property of the GridView, so GridView1_RowCommand method won't be fired when you click the image button. Here's how you do it
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
Width="505px" DataSourceID="SqlDataSource1"
OnRowCommand="GridView1_RowCommand">
See here for more details.

How I can open a ModalDialog about a LinkButton from a ListView

I want open a Dialog with Controls and it must open if I click on a LinkButton in a ListView. I want make it with a CommandName and OnCommand Argumen.
My Application:
In My Application can a User search other Users about a textBox and list the users in a ListView. Than he can display more Informations about one User if the user click on the LinkButton.
If I make it about a normal Button, the Dialog open but if I make it about the LinkButton with CommandName it Don't work.
My Code:
<form id="form1" runat="server">
<asp:HiddenField ID="hidForModel" runat="server" />
<asp:scriptmanager id="ScriptManager1" runat="server">
</asp:scriptmanager>
<asp:modalpopupextender id="ModalPopupExtender1"
runat="server" cancelcontrolid="btnCancel"
okcontrolid="btnOkay" targetcontrolid="hidForModel"
popupcontrolid="Panel1" popupdraghandlecontrolid="PopupHeader"
drag="true" backgroundcssclass="ModalPopupBG">
</asp:modalpopupextender>
<div class="popupConfirmation" id="Panel1" >
<asp:Panel runat="server" ID="PopupHeader" CssClass="modalPopup">Benutzerinformationen</asp:Panel>
<div class="Body">
Hallo
<asp:Button id="btnOkay" runat="server" text="Speichern" />
<asp:Button id="btnCancel" runat="server" text="Abbrechen" />
</div>
</div>
<div class="header">
<table id="SuchTabelle" runat="server" border="0">
<tr>
<th><asp:Label ID="id_SearchUser" runat="server" Text="lblSearchUser"></asp:Label></th>
<th><asp:TextBox ID="txtBenutzer" runat="server" Width="250px"></asp:TextBox></th>
</tr>
<tr>
<th><asp:Label ID="id_location" runat="server" Text="lblLocation"></asp:Label></th>
<th><asp:DropDownList ID="dropWerk" runat="server" Width="250px" /></th>
<th><asp:Button ID="Button2" runat="server" Text="Suchen"
onclick="btnBenutzerSuchen_Click" Width="219px" /></th>
</tr>
</table>
<div id="bild">
<asp:Image runat="server" ImageUrl="~/App_Theme/lw_logo.jpg" Height="58px"
Width="277px" />
</div>
</div>
<div class="bodyList">
<asp:ListView runat="server" ID="myListView">
<LayoutTemplate>
<table id="UserTable" runat="server" border="0" width="800" cellpadding="0" cellspacing="0">
<tr style="background-color:#E5E5FE" class="TableClass">
<th id="th1" runat="server"><asp:LinkButton ID="lnkBenutzer" runat="server" >id_Benutzer</asp:LinkButton></th>
<th id="th2" runat="server"><asp:LinkButton ID="lnkemail" runat="server" >id_Email</asp:LinkButton></th>
<th id="th3" runat="server"><asp:LinkButton ID="lnkVorname" runat="server" >id_Vorname</asp:LinkButton></th>
<th id="th4" runat="server"><asp:LinkButton ID="lnkNachname" runat="server" >id_Nachname</asp:LinkButton></th>
<th id="th5" runat="server"><asp:LinkButton ID="lnkTelefon" runat="server" >id_Telefon</asp:LinkButton></th>
</tr>
<tr runat="server" id="ItemPlaceholder">
</tr>
</table>
</LayoutTemplate>
<ItemTemplate>
<tr class="TableClass">
<td align="left" ><asp:LinkButton CssClass="MyLink" OnCommand="Button1_Command" CommandName="Select" CommandArgument='<%# Container.DataItemIndex %>' ID="Label1" Text='<%# Eval("Benutzername") %>' runat="server" /></td>
<td align="left"><asp:LinkButton CssClass="MyLink" OnCommand="Button1_Command" CommandName="Select" CommandArgument='<%# Container.DataItemIndex %>' ID="Label2" Text='<%# Eval("eMail") %>' runat="server" /></td>
<td align="left"><asp:LinkButton CssClass="MyLink" OnCommand="Button1_Command" CommandName="Select" CommandArgument='<%# Container.DataItemIndex %>' ID="Label3" Text='<%# Eval("Vorname") %>' runat="server" /></td>
<td align="left"><asp:LinkButton CssClass="MyLink" OnCommand="Button1_Command" CommandName="Select" CommandArgument='<%# Container.DataItemIndex %>' ID="Label4" Text='<%# Eval("Nachname") %>' runat="server" /></td>
<td align="left"><asp:LinkButton CssClass="MyLink" OnCommand="Button1_Command" CommandName="Select" CommandArgument='<%# Container.DataItemIndex %>' ID="Label5" Text='<%# Eval("Telefonnummer") %>' runat="server" /></td>
<td align="left"><asp:Label ID="Label6" Text='<%# Eval("GUID") %>' runat="server" Visible="False" /></td>
</tr>
</ItemTemplate>
<AlternatingItemTemplate>
<tr class="TableClass">
<td align="left" ><asp:LinkButton CssClass="MyLink" OnCommand="Button1_Command" CommandName="Select" CommandArgument='<%# Container.DataItemIndex %>' ID="Label1" Text='<%# Eval("Benutzername") %>' runat="server" /></td>
<td align="left"><asp:LinkButton CssClass="MyLink" OnCommand="Button1_Command" CommandName="Select" CommandArgument='<%# Container.DataItemIndex %>' ID="Label2" Text='<%# Eval("eMail") %>' runat="server" /></td>
<td align="left"><asp:LinkButton CssClass="MyLink" OnCommand="Button1_Command" CommandName="Select" CommandArgument='<%# Container.DataItemIndex %>' ID="Label3" Text='<%# Eval("Vorname") %>' runat="server" /></td>
<td align="left"><asp:LinkButton CssClass="MyLink" OnCommand="Button1_Command" CommandName="Select" CommandArgument='<%# Container.DataItemIndex %>' ID="Label4" Text='<%# Eval("Nachname") %>' runat="server" /></td>
<td align="left"><asp:LinkButton CssClass="MyLink" OnCommand="Button1_Command" CommandName="Select" CommandArgument='<%# Container.DataItemIndex %>' ID="Label5" Text='<%# Eval("Telefonnummer") %>' runat="server" /></td>
<td align="left"><asp:Label ID="Label6" Text='<%# Eval("GUID") %>' runat="server" Visible="False" /></td>
</tr>
</AlternatingItemTemplate>
</asp:ListView>
<br />
<br />
</div>
</form>
My C# Code:
protected void Button1_Command(object sender, CommandEventArgs e)
{
if (e.CommandName == "Select")
{
ModalPopupExtender1.Show(); // error :(
}
}
My Errortext:
System.InvalidOperationException: The ListView "myListView" has one SelectedIndexChanging-Event execute, which was not treated.
I need help :(
The Update:
protected void myListView_ItemCommand(object sender, ListViewCommandEventArgs e)
{
if (e.CommandName == "Select")
{
txtVorname.Text = "test";
PopUpDialog.Show(); //<-- Here is the error
}
}
I make a breakpoint and see ...
tarasov
Try this:
Handle "ItemCommand" Event of "ListView":
protected void myListView_ItemCommand(object sender, ListViewCommandEventArgs e)
{
if (String.Equals(e.CommandName, "Select"))
{
ModalPopupExtender1.Show();
//your code
}
}

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