Can a TargetControlID of a PopUp use the Button of a GridView? - asp.net

I have a Button with id=btnSend that named "Send" in GridView.
I have a ModalPopUpExtender id="SendPopUp" and TargetControlID="btnSend"
and
<asp:Panel id="SendPanel">
I get the error as
System.InvalidOperationException: The TargetControlID of '
SendPopUp'is not valid. A control with ID 'btnSend' could not be
found.
How do I make it work?

You need to add the Click event of button then from code behind file you can show model popup by simply write code in button click event
modal.show()
For your reference i am providing you complete code as follow.
I hope it will help you.
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
<style type="text/css">
.modalBackground
{
background-color: Gray;
filter: alpha(opacity=80);
opacity: 0.8;
z-index: 10000;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<asp:ToolkitScriptManager ID="ScriptManager1" runat="server">
</asp:ToolkitScriptManager>
<div>
<asp:GridView runat="server" ID="gvdetails" DataKeyNames="UserId" AutoGenerateColumns="false">
<RowStyle BackColor="#EFF3FB" />
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:TemplateField HeaderText="Edit">
<ItemTemplate>
<asp:ImageButton ID="imgbtn" ImageUrl="~/Edit.jpg" runat="server" Width="25" Height="25" onclick="imgbtn_Click" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="UserName" HeaderText="UserName" />
<asp:BoundField DataField="FirstName" HeaderText="FirstName" />
<asp:BoundField DataField="LastName" HeaderText="LastName" />
<asp:BoundField DataField="City" HeaderText="City" />
<asp:BoundField DataField="Designation" HeaderText="Designation" />
</Columns>
</asp:GridView>
<asp:Label ID="lblresult" runat="server"/>
<asp:Button ID="btnShowPopup" runat="server" style="display:none" />
<asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="btnShowPopup" PopupControlID="pnlpopup"
CancelControlID="btnCancel" BackgroundCssClass="modalBackground">
</asp:ModalPopupExtender>
<asp:Panel ID="pnlpopup" runat="server" BackColor="White" Height="269px" Width="400px" style="display:none">
<table width="100%" style="border:Solid 3px #D55500; width:100%; height:100%" cellpadding="0" cellspacing="0">
<tr style="background-color:#D55500">
<td colspan="2" style=" height:10%; color:White; font-weight:bold; font-size:larger" align="center">User Details</td>
</tr>
<tr>
<td align="right" style=" width:45%">
UserId:
</td>
<td>
<asp:Label ID="lblID" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td align="right">
UserName:
</td>
<td>
<asp:Label ID="lblusername" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td align="right">
FirstName:
</td>
<td>
<asp:TextBox ID="txtfname" runat="server"/>
</td>
</tr>
<tr>
<td align="right">
LastName:
</td>
<td>
<asp:TextBox ID="txtlname" runat="server"/>
</td>
</tr>
<tr>
<td align="right">
City:
</td>
<td>
<asp:TextBox ID="txtCity" runat="server"/>
</td>
</tr>
<tr>
<td align="right">
Designation:
</td>
<td>
<asp:TextBox ID="txtDesg" runat="server"/>
</td>
</tr>
<tr>
<td>
</td>
<td>
<asp:Button ID="btnUpdate" CommandName="Update" runat="server" Text="Update" onclick="btnUpdate_Click"/>
<asp:Button ID="btnCancel" runat="server" Text="Cancel" />
</td>
</tr>
</table>
</asp:Panel>
</div>
</form>
</body>
</html>
Code Behind file
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["dbconnection"].ToString());
protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
BindGridData();
}
}
protected void BindGridData()
{
con.Open();
SqlCommand cmd = new SqlCommand("Select * from Employee_Details", con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
gvdetails.DataSource = dt;
gvdetails.DataBind();
}
protected void btnUpdate_Click(object sender, EventArgs e)
{
con.Open();
SqlCommand cmd = new SqlCommand("update Employee_Details set FirstName=#FirstName,LastName=#LastName, City=#City,Designation=#Designation where UserId=#UserId", con);
cmd.Parameters.AddWithValue("#FirstName", txtfname.Text);
cmd.Parameters.AddWithValue("#LastName", txtlname.Text);
cmd.Parameters.AddWithValue("#City", txtCity.Text);
cmd.Parameters.AddWithValue("#Designation", txtDesg.Text);
cmd.Parameters.AddWithValue("#UserId", Convert.ToInt32(lblID.Text));
cmd.ExecuteNonQuery();
con.Close();
lblresult.Text = lblusername.Text + " Details Updated Successfully";
lblresult.ForeColor = Color.Green;
BindGridData();
}
protected void imgbtn_Click(object sender, ImageClickEventArgs e)
{
ImageButton btndetails = sender as ImageButton;
GridViewRow gvrow = (GridViewRow)btndetails.NamingContainer;
lblID.Text = gvdetails.DataKeys[gvrow.RowIndex].Value.ToString();
lblusername.Text = gvrow.Cells[1].Text;
txtfname.Text = gvrow.Cells[2].Text;
txtlname.Text = gvrow.Cells[3].Text;
txtCity.Text = gvrow.Cells[4].Text;
txtDesg.Text = gvrow.Cells[5].Text;
this.ModalPopupExtender1.Show();
}

since your panel if outside of the gridview it wont work this way. add a hiddenfield and set the targetcontrolid to that field. Next in the button click of the gridview use modalpopup.show();

Related

asp.net gridview - spread bound data across multi lines per row with updatepanel

I have a panel inside a gridview and I need it to be 'spread' for the width of the row :
never mind what's in the panel. What I show here is just to demo my needs...My HTML:
<asp:GridView ID="GridView1" runat="server"
AutoGenerateColumns="False"
CellPadding="3"
CssClass="myGrid"
DataKeyNames="Role_Name">
<AlternatingRowStyle BackColor="#E6E6E6" />
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:ImageButton ID="imgShow" runat="server" OnClick="Show_Hide_details" BorderStyle="None" BackColor="Transparent" ImageUrl="~/Content/Images/Arrow_Down.png"
CommandArgument="Show" />
<asp:Panel ID="pnlRole" runat="server" Style="position: relative;" Visible="false">
<asp:Label ID="lblAAA" runat="server" Text="aaa" /><br />
<asp:Label ID="lblBBB" runat="server" Text="bbb" /><br />
<asp:Label ID="lblCCC" runat="server" Text="ccc" /><br />
<asp:Label ID="lblDDD" runat="server" Text="ddd" /><br />
</asp:Panel>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Role_Name" HeaderText="Name">
<HeaderStyle Width="100px" />
<ItemStyle CssClass="myGridItemMaxWidth" HorizontalAlign="Left" Wrap="false" />
</asp:BoundField>
<asp:BoundField DataField="Role_Description" HeaderText="Description">
<HeaderStyle Width="150px" />
<ItemStyle CssClass="myGridItemMaxWidth" HorizontalAlign="Left" Wrap="false" />
</asp:BoundField>
</Columns>
<HeaderStyle CssClass="myGridHeader" />
<RowStyle ForeColor="#000066" />
</asp:GridView>
I'd appreciate any help/idea/solution.
EDIT :
To better explain my problem, here's another image :
(never mind what's in the panel. What I show here is just to demo my needs...)
It's tough to do that properly inside of a GridView without it becoming unwieldy.
You would better off with a ListView and using the functionality there.
<asp:ListView ID="ListView1" runat="server"
DataKeyNames="Role_Name"
OnItemCommand="ListView1_ItemCommand">
<LayoutTemplate>
<table class="myGrid">
<thead>
<tr>
<th></th>
<th>Name</th>
<th>Description</th>
</tr>
</theah>
<tbody>
<asp:PlaceHolder ID="itemPlaceholder" runat="server" />
</tbody>
</table>
</LayoutTemplate>
<ItemTemplate>
<tr>
<td>
<asp:ImageButton ID="imgShow" runat="server" BorderStyle="None" BackColor="Transparent" ImageUrl="~/Content/Images/Arrow_Down.png" CommandName="Toggle" />
</td>
<td><%# Eval("Role_Name") %></td>
<td><%# Eval("Role_Description") %></td>
</tr>
<tr>
<td colspan="3">
<asp:Panel ID="pnlRole" runat="server" Style="position: relative;" Visible="false">
<asp:Label ID="lblAAA" runat="server" Text="aaa" /><br />
<asp:Label ID="lblBBB" runat="server" Text="bbb" /><br />
<asp:Label ID="lblCCC" runat="server" Text="ccc" /><br />
<asp:Label ID="lblDDD" runat="server" Text="ddd" /><br />
</asp:Panel>
</td>
</tr>
</ItemTemplate>
<EmptyDataTemplate>
<p>No data found.</p>
</EmptyDataTemplate>
</asp:ListView>
This will unfortunately have an extra <tr>...</tr> for each row. To resolve that, a way you could do this is to use runat="server" for the <tr> in place of the Panel.
<tr id="pnlRole" runat="server" Visible="false">
<td colspan="3">
<asp:Label ID="lblAAA" runat="server" Text="aaa" /><br />
<asp:Label ID="lblBBB" runat="server" Text="bbb" /><br />
<asp:Label ID="lblCCC" runat="server" Text="ccc" /><br />
<asp:Label ID="lblDDD" runat="server" Text="ddd" /><br />
</td>
</tr>
Now in the code-behind you can reference this
protected void ListView1_ItemCommand(object sender, ListViewCommandEventArgs e)
{
if (e.CommandName == "Toggle")
{
HtmlTableRow pnlRole = e.Item.FindControl("pnlRole") as HtmlTableRow;
pnlRole.Visible = !pnlRole.Visible;
ImageButton imgShow = e.Item.FindControl("imgShow") as ImageButton;
if (pnlRole.Visible == true)
imgShow.ImageUrl="~/Content/Images/Arrow_Down.png";
else
imgShow.ImageUrl="~/Content/Images/Arrow_Up.png";
}
}
Here is what I came up with -
On the left is the GridView when all rows are 'closed'. On the right, after 'opening' 2 rows:
Markup:
<form id="form1" runat="server" style="">
<asp:ScriptManager runat="server"></asp:ScriptManager>
<table runat="server" style="font-weight: bold; margin: 0 auto; font-family: Arial;">
<tr>
<td style="text-align: center; width: 500px; overflow: hidden">
<asp:GridView ID="grv_Four_Rows" runat="server"
AutoGenerateColumns="False" BackColor="black" GridLines="None"
CellPadding="3" CssClass="myGrid" DataKeyNames="Test1_First_Name">
<HeaderStyle CssClass="myGridHeader" />
<RowStyle BackColor="#b5c7de" />
<AlternatingRowStyle BackColor="#d1e0e0" />
<Columns>
<asp:TemplateField>
<ItemStyle HorizontalAlign="Left" />
<HeaderTemplate>
<table>
<tr>
<td style="width: 150px;">First</td>
<td style="width: 150px;">Last</td>
</tr>
</table>
</HeaderTemplate>
<ItemTemplate>
<table>
<td>
<asp:UpdatePanel ID="upp_Main_Row" runat="server">
<ContentTemplate>
<asp:Panel runat="server">
<td>
<asp:ImageButton ID="imgShow" runat="server" OnClick="Show_Hide_details"
ImageUrl="~/Content/Images/Arrow_Down.png" CommandArgument="Show" />
</td>
<td style="width: 150px"><%# Eval("Test1_First_Name")%></td>
<td style="width: 150px"><%# Eval("Test1_Last_Name")%></td>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
</td>
</table>
<table style="border-style: solid; border-width: thin; width: 100%">
<asp:UpdatePanel ID="upp_2nd_row" runat="server" Visible="false">
<ContentTemplate>
<tr>
<td>
<a style="color: red">Address: </a><%# Eval("Test1_Address")%>
</td>
</tr>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel ID="upp_3rd_row" runat="server" Visible="false">
<ContentTemplate>
<tr>
<td>
<a style="color: red;">Description: </a><%#Eval("Test1_Description")%>
</td>
</tr>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel ID="upp_4th_row" runat="server" Visible="false">
<ContentTemplate>
<tr style="float: left">
<td>
<a style="color: red">Note1: </a><%#Eval("Test1_Note_1")%>
<a style="color: red">Note2: </a><%#Eval("Test1_Note_2")%>
</td>
</tr>
</ContentTemplate>
</asp:UpdatePanel>
</table>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</td>
</tr>
</table>
</form>
<style type="text/css">
.myGrid {
border: 1px solid black;
-webkit-border-radius: 8px;
-moz-border-radius: 8px;
border-radius: 8px;
overflow: hidden;
background-color: white;
text-align: center;
margin: 0 auto;
}
.myGridHeader > th {
text-align: center;
border: solid 1px;
font-family: Arial;
background-color: #DDFFD6;
font-weight: bold;
color: #000066;
}
</style>
C# code-behind:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
load_grv_Four_Rows();
}
}
//================================================================================================
protected void Show_Hide_details(object sender, EventArgs e)
{
ImageButton imgShowHide = sender as ImageButton;
GridViewRow row = imgShowHide.NamingContainer as GridViewRow;
if (imgShowHide.CommandArgument == "Show")
{
row.FindControl("upp_2nd_Row").Visible = true;
row.FindControl("upp_3rd_Row").Visible = true;
row.FindControl("upp_4th_Row").Visible = true;
imgShowHide.CommandArgument = "Hide";
imgShowHide.ImageUrl = "~/Content/Images/Arrow_Up.png";
}
else
{
row.FindControl("upp_2nd_Row").Visible = false;
row.FindControl("upp_3rd_Row").Visible = false;
row.FindControl("upp_4th_Row").Visible = false;
imgShowHide.CommandArgument = "Show";
imgShowHide.ImageUrl = "~/Content/Images/Arrow_Down.png";
}
}
//================================================================================================
private void load_grv_Four_Rows()
{
try
{
SqlConnection con;
DataSet ds;
con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["BETSEFER_DB"].ConnectionString);
string CmdString = "SELECT * FROM tbl_Test1 ORDER BY Test1_First_Name";
ds = new DataSet();
using (SqlDataAdapter sda = new SqlDataAdapter(CmdString, con))
{
sda.Fill(ds);
if (ds.Tables.Count > 0)
{
DataView dv = ds.Tables[0].DefaultView;
grv_Four_Rows.DataSource = dv;
grv_Four_Rows.DataBind();
}
}
}
catch (SqlException ex)
{
Session["mySQL_Error_Msg"] = ex.Message;
Server.ClearError();
Response.Redirect("~/Errors.aspx");
}
}
//================================================================================================
The table:
I still have lots of formatting and cosmetic issues but for those I'll open a new post.
Hope it helps someone.

How to change submit button to update button

I guys i have two page On fist page i have my form and on second is report page where my form values store in grid. i have submit button on my form page now when i click on edit link i will redirect to my form page where i can make change and update details. now what i want is when i click on edit link and move to my form page to make editing my submit button change to update button how can i do that...
here is my code for first page:
Select
TRAVELONG
ONETRAVEL
.UK-BSP
.CA-YYZ
.CA-YVR
Partial MCO Refund
<div id="FirstForm" style="margin-left: 80px" runat="server">
<table class="style1">
<tr>
<td class="style13">
<asp:Label ID="lblTid" runat="server" Text="TID"></asp:Label>
</td>
<td class="style5">
<asp:TextBox ID="tbTid" runat="server"></asp:TextBox>
</td>
<td class="style4">
<asp:RequiredFieldValidator ID="rfvTid" runat="server"
ControlToValidate="tbTid" ErrorMessage="Enter Tid" Font-Bold="True"
ForeColor="Red">*</asp:RequiredFieldValidator>
</td>
<td class="style5">
<asp:Label ID="lblUnusedTicketAmount" runat="server"
Text="Unused Ticket Amount"></asp:Label>
</td>
<td class="style11">
<asp:TextBox ID="tbUnusedTicketAmount" runat="server"></asp:TextBox>
</td>
<td>
<asp:RequiredFieldValidator ID="rfvUnusedTicketAmount" runat="server"
ControlToValidate="tbUnusedTicketAmount" ErrorMessage="Enter Amount"
Font-Bold="True" ForeColor="Red">*</asp:RequiredFieldValidator>
</td>
<td>
<asp:DropDownList ID="ddlUnusedAmount" runat="server">
<asp:ListItem>USD</asp:ListItem>
<asp:ListItem>CAD</asp:ListItem>
<asp:ListItem>GBP</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="style14">
<asp:Label ID="lblPNR" runat="server" Text="PNR"></asp:Label>
</td>
<td class="style9">
<asp:TextBox ID="tbPNR" runat="server"></asp:TextBox>
</td>
<td class="style8">
<asp:RequiredFieldValidator ID="rfvPNR" runat="server"
ControlToValidate="tbPNR" ErrorMessage="Enter PNR" Font-Bold="True"
ForeColor="Red">*</asp:RequiredFieldValidator>
</td>
<td class="style9">
<asp:Label ID="lblAirlinePenality" runat="server" Text="Airline Penality"></asp:Label>
</td>
<td class="style12">
<asp:TextBox ID="tbAirlinePenality" runat="server"></asp:TextBox>
</td>
<td class="style10">
<asp:RequiredFieldValidator ID="rfvAirlinePenality" runat="server"
ControlToValidate="tbAirlinePenality" ErrorMessage="Enter Penality"
Font-Bold="True" ForeColor="Red">*</asp:RequiredFieldValidator>
</td>
<td class="style10">
<asp:DropDownList ID="ddlAirlinePenality" runat="server" AutoPostBack="True">
<asp:ListItem>USD</asp:ListItem>
<asp:ListItem>CAD</asp:ListItem>
<asp:ListItem>GBP</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="style13">
<asp:Label ID="lblTicketNumber" runat="server" Text="Ticket Number"></asp:Label>
</td>
<td class="style5">
<asp:TextBox ID="tbTicketNumber" runat="server"></asp:TextBox>
</td>
<td class="style4">
<asp:RequiredFieldValidator ID="rfvTicketNumber" runat="server"
ControlToValidate="tbTicketNumber" ErrorMessage="Enter ESAC" Font-Bold="True"
ForeColor="Red">*</asp:RequiredFieldValidator>
</td>
<td class="style5">
<asp:Label ID="lblNetRefundProcess" runat="server" Text="Net Refund Process"></asp:Label>
</td>
<td class="style11">
<asp:TextBox ID="tbNetRefundProcess" runat="server"></asp:TextBox>
</td>
<td>
<asp:RequiredFieldValidator ID="rfvNetRefundProcess" runat="server"
ControlToValidate="tbNetRefundProcess" ErrorMessage="RequiredFieldValidator"
Font-Bold="True" ForeColor="Red">*</asp:RequiredFieldValidator>
</td>
<td>
<asp:DropDownList ID="ddlNetRefundProcess" runat="server" AutoPostBack="True">
<asp:ListItem>USD</asp:ListItem>
<asp:ListItem>CAD</asp:ListItem>
<asp:ListItem>GBP</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="style13">
<asp:Label ID="lblESACCode" runat="server" Text="ESAC Code"></asp:Label>
</td>
<td class="style5">
<asp:TextBox ID="tbESACCode" runat="server"></asp:TextBox>
</td>
<td class="style4">
<asp:RequiredFieldValidator ID="rfvESACCode" runat="server"
ControlToValidate="tbESACCode" ErrorMessage="Enter ESAC code" Font-Bold="True"
ForeColor="Red">*</asp:RequiredFieldValidator>
</td>
<td class="style5">
<asp:Label ID="lblRefundableCommision" runat="server"
Text="Refundable Commission"></asp:Label>
</td>
<td class="style11">
<asp:TextBox ID="tbRefundableCommision" runat="server"></asp:TextBox>
</td>
<td>
<asp:RequiredFieldValidator ID="rfvRefundableCommission" runat="server"
ControlToValidate="tbRefundableCommision" ErrorMessage="RequiredFieldValidator"
Font-Bold="True" ForeColor="Red">*</asp:RequiredFieldValidator>
</td>
<td>
<asp:DropDownList ID="ddlRefundableCommission" runat="server"
AutoPostBack="True">
<asp:ListItem>USD</asp:ListItem>
<asp:ListItem>CAD</asp:ListItem>
<asp:ListItem>GBP</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="style13">
<asp:Label ID="lblWaiverCode" runat="server" Text="Waiver Code"></asp:Label>
</td>
<td class="style5">
<asp:TextBox ID="tbWaiverCode" runat="server"></asp:TextBox>
</td>
<td class="style4">
<asp:RequiredFieldValidator ID="rfvWaiverCode" runat="server"
ControlToValidate="tbWaiverCode" ErrorMessage="Enter Waiver Code"
Font-Bold="True" ForeColor="Red">*</asp:RequiredFieldValidator>
</td>
<td class="style5">
<asp:Label ID="lblCouponRefunded" runat="server" Text="Coupon Refunded"></asp:Label>
</td>
<td class="style11">
<asp:TextBox ID="tbCouponRefund" runat="server"></asp:TextBox>
</td>
<td>
<asp:RequiredFieldValidator ID="rfvCouponRefunded" runat="server"
ControlToValidate="tbCouponRefund" ErrorMessage="Enter Coupon Refund"
Font-Bold="True" ForeColor="Red">*</asp:RequiredFieldValidator>
</td>
<td>
</td>
</tr>
<tr>
<td class="style13">
<asp:Label ID="Label7" runat="server" Text="Remarks"></asp:Label>
</td>
<td class="style5">
<asp:TextBox ID="tbRemarks" runat="server" TextMode="MultiLine"></asp:TextBox>
</td>
<td class="style4">
<asp:RequiredFieldValidator ID="rfvRemarks" runat="server"
ControlToValidate="tbRemarks" ErrorMessage="Enter Remarks" Font-Bold="True"
ForeColor="Red">*</asp:RequiredFieldValidator>
</td>
<td class="style5">
<asp:Label ID="lblRefundType" runat="server" Text="Refund Type"></asp:Label>
</td>
<td class="style11">
<asp:DropDownList ID="ddlRefundType" runat="server">
<asp:ListItem>Full</asp:ListItem>
<asp:ListItem>Partial</asp:ListItem>
</asp:DropDownList>
</td>
<td>
<asp:RequiredFieldValidator ID="rfvRefundType" runat="server"
ControlToValidate="ddlRefundType" ErrorMessage="Select Refund Type"
Font-Bold="True" ForeColor="Red">*</asp:RequiredFieldValidator>
</td>
<td>
</td>
</tr>
<tr>
<td class="style13" colspan="7">
<asp:Button ID="btnSubmit" runat="server" onclick="btnSubmit_Click" Text="Submit"/>
<asp:Button ID="btnReset" runat="server" onclick="btnReset_Click" Text="Reset"/>
</td>
</tr>
</table>
aspx.cs page code:
protected void btnSubmit_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=Bart;Integrated Security=True");
con.Open();
string Portal = ddlPortal.SelectedValue;
string TID = tbTid.Text;
string PNR = tbPNR.Text;
string TicketNumber = tbTicketNumber.Text;
string ESACCode = tbESACCode.Text;
string WaiverCode = tbWaiverCode.Text;
string Remarks = tbRemarks.Text;
string UnusedTicketAmount = tbUnusedTicketAmount.Text;
string UnusedAmount = ddlUnusedAmount.SelectedValue;
string AirlinePenality = tbAirlinePenality.Text;
string Airline = ddlAirlinePenality.SelectedValue;
string NetRefundProcess = tbNetRefundProcess.Text;
string NetRefund = ddlNetRefundProcess.SelectedValue;
string RefundableCommission = tbRefundableCommision.Text;
string Refundable = ddlRefundableCommission.SelectedValue;
string CouponRefunded = tbCouponRefund.Text;
string RefundType = ddlRefundType.SelectedValue;
using (SqlCommand cmd = con.CreateCommand())
{
cmd.CommandText = "insert into Form3(Portal,TID,PNR,TicketNumber,ESACCode,WaiverCode,Remarks,UnusedTicketAmount,ddlUnusedAmount, AirlinePenality, ddlAirlinePenality, NetRefundProcess, ddlNetRefundProcess, RefundableCommission, ddlRefundableCommission, CouponRefunded,RefundType) values('" + Portal + "','" + TID + "','" + PNR + "','" + TicketNumber + "', '" + ESACCode + "', '" + WaiverCode + "', '" + Remarks + "','" + UnusedTicketAmount + "','" + UnusedAmount + "','" + AirlinePenality + "','" + Airline + "','" + NetRefundProcess + "','" + NetRefund + "','" + RefundableCommission + "','" + Refundable + "','" + CouponRefunded + "','" + RefundType + "')";
cmd.Parameters.AddWithValue("#Portal", ddlPortal.SelectedIndex);
cmd.Parameters.AddWithValue("#TID", tbTid.Text.Trim());
cmd.Parameters.AddWithValue("#PNR", tbPNR.Text.Trim());
cmd.Parameters.AddWithValue("#TicketNumber", tbTicketNumber.Text.Trim());
cmd.Parameters.AddWithValue("#ESACCode", tbESACCode.Text.Trim());
cmd.Parameters.AddWithValue("#WaiverCode", tbWaiverCode.Text.Trim());
cmd.Parameters.AddWithValue("#Remarks", tbRemarks.Text.Trim());
cmd.Parameters.AddWithValue("#UnusedTicketAmount", tbUnusedTicketAmount.Text.Trim());
cmd.Parameters.AddWithValue("#ddlUnusedAmount", ddlUnusedAmount.SelectedIndex);
cmd.Parameters.AddWithValue("#AirlinePenality", tbAirlinePenality.Text.Trim());
cmd.Parameters.AddWithValue("#ddlAirlinePenality", ddlAirlinePenality.SelectedIndex);
cmd.Parameters.AddWithValue("#NetRefundProcess", tbNetRefundProcess.Text.Trim());
cmd.Parameters.AddWithValue("#ddlNetRefundProcess", ddlNetRefundProcess.SelectedIndex);
cmd.Parameters.AddWithValue("#RefundableCommission", tbRefundableCommision.Text.Trim());
cmd.Parameters.AddWithValue("#ddlRefundableCommission", ddlRefundableCommission.SelectedIndex);
cmd.Parameters.AddWithValue("#CouponRefunded", tbCouponRefund.Text.Trim());
cmd.Parameters.AddWithValue("#RefundType", ddlRefundType.SelectedIndex);
cmd.ExecuteNonQuery();
}
con.Close();
tbTid.Text = "";
tbPNR.Text = "";
tbTicketNumber.Text = "";
tbESACCode.Text = "";
tbWaiverCode.Text = "";
tbRemarks.Text = "";
tbRemarks.Text = "";
tbUnusedTicketAmount.Text = "";
tbAirlinePenality.Text = "";
tbNetRefundProcess.Text = "";
tbRefundableCommision.Text = "";
tbCouponRefund.Text = "";
lblRefundType.Text = "";
tbTid.Focus();
}
Second report page::
<asp:GridView ID="GridView1" runat="server" CellPadding="4" ForeColor="#333333"
GridLines="None" AutoGenerateColumns="False"
onrowcommand="GridView1_RowCommand1">
<Columns>
<asp:TemplateField HeaderText="Query">
<itemtemplate>
<asp:LinkButton CommandName="cmdBind" runat="server" Text='<%#Eval("ID")%>' ID="ID" ToolTip='<%#Eval("ID")%>'>LinkButton
</asp:LinkButton>
</itemtemplate>
</asp:TemplateField>
<asp:BoundField DataField="Portal" HeaderText="Portal" ItemStyle-HorizontalAlign="Center"/>
<asp:BoundField DataField="TID" HeaderText="TID" ItemStyle-HorizontalAlign="Center"/>
<asp:BoundField DataField="PNR" HeaderText="PNR" ItemStyle-HorizontalAlign="Center"/>
<asp:BoundField DataField="TicketNumber" HeaderText="Ticket Number" ItemStyle-HorizontalAlign="Center"/>
<asp:BoundField DataField="ESACCode" HeaderText="ESACCode" ItemStyle-HorizontalAlign="Center"/>
<asp:BoundField DataField="WaiverCode" HeaderText="WaiverCode" ItemStyle-HorizontalAlign="Center"/>
<asp:BoundField DataField="Remarks" HeaderText="Remarks" ItemStyle-HorizontalAlign="Center"/>
<asp:BoundField DataField="UnusedTicketAmount" HeaderText="UnusedTicketAmount" ItemStyle-HorizontalAlign="Center"/>
<asp:BoundField DataField="ddlUnusedAmount" HeaderText="ddlUnusedAmoun" ItemStyle-HorizontalAlign="Center"/>
<asp:BoundField DataField="AirlinePenality" HeaderText="AirlinePenality" ItemStyle-HorizontalAlign="Center"/>
<asp:BoundField DataField="ddlAirlinePenality" HeaderText="ddlAirlinePenality" ItemStyle-HorizontalAlign="Center"/>
<asp:BoundField DataField="NetRefundProcess" HeaderText="NetRefundProcess" ItemStyle-HorizontalAlign="Center"/>
<asp:BoundField DataField="ddlNetRefundProcess" HeaderText="ddlNetRefundProcess" ItemStyle-HorizontalAlign="Center"/>
<asp:BoundField DataField="RefundableCommission" HeaderText="RefundableCommission" ItemStyle-HorizontalAlign="Center"/>
<asp:BoundField DataField="ddlRefundableCommission" HeaderText="ddlRefundableCommission" ItemStyle-HorizontalAlign="Center"/>
<asp:BoundField DataField="CouponRefunded" HeaderText="CouponRefunded" ItemStyle-HorizontalAlign="Center"/>
<asp:BoundField DataField="RefundType" HeaderText="RefundType" ItemStyle-HorizontalAlign="Center"/>
</Columns>
<AlternatingRowStyle BackColor="White" />
<EditRowStyle BackColor="#2461BF" />
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#EFF3FB" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#F5F7FB" />
<SortedAscendingHeaderStyle BackColor="#6D95E1" />
<SortedDescendingCellStyle BackColor="#E9EBEF" />
<SortedDescendingHeaderStyle BackColor="#4870BE" />
</asp:GridView>
aspx.cs page of report:
protected void Page_Load(object sender, EventArgs e)
{
try
{
if (!Page.IsPostBack)
{
cmd = new SqlCommand("select * from Form3", con);
da = new SqlDataAdapter(cmd);
dt.Clear();
con.Open();
da.Fill(dt);
if (dt.Rows.Count > 0)
{
GridView1.DataSource = dt;
GridView1.DataBind();
}
con.Close();
}
}
catch (Exception ex)
{
Response.Write(ex.ToString());
}
}
protected void GridView1_RowCommand1(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "cmdBind")
{
LinkButton lb = (LinkButton)e.CommandSource;
Response.Redirect("Form.aspx?ID=" + lb.Text + "");
}
}
You need to use a State Management technique to implement this. I have used Session to demonstrate.
On your page where you have the Submit button you need to create a property like this:
public string ButtonTextValue
{
get
{
if (Session["ButtonValue"] == null)
Session["ButtonValue"] = "Submit";
return Convert.ToString(Session["ButtonValue"]);
}
set
{
Session["ButtonValue"] = value;
}
}
On pageload of the same page you need to do this:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
YourButton.Text = ButtonTextValue;
}
}
And on the second page you need to do this:
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "cmdBind")
{
LinkButton lb = (LinkButton)e.CommandSource;
Session["ButtonValue"] = "Update";
Response.Redirect("Form.aspx?ID=" + lb.Text + "");
}
}

How to get the selected item of listbox placed inside GridView? Did not work on first event

Getting the selected value on clicking button twice. But not working when click once
<asp:GridView ID="viewgrid" runat="server" AutoGenerateColumns="False"
OnRowCommand="viewgrid_RowCommand" OnRowDataBound="viewgrid_RowDataBound"
DataKeyNames="RegionID" >
<AlternatingRowStyle BackColor="#DCDCDC" />
<Columns>
<asp:TemplateField HeaderText="RegionName">
<HeaderStyle BackColor="#4B6C9E" ForeColor="White" />
<ItemTemplate>
<table style="width: 200px">
<tr>
<td>
<asp:Label ID="lblregion" runat="server"
Text='<%# Eval("name") %>' ToolTip='<%# Eval("RegionID") %>'>
</asp:Label><br />
</td>
</tr>
<tr>
<td>
<asp:ListBox ID="listlocation" runat="server" Width="200px"
Height="38px" SelectionMode="Multiple"
AppendDataBoundItems="true"></asp:ListBox>
</td>
</tr>
</table>
</ItemTemplate>
<FooterTemplate>
</FooterTemplate>
<FooterStyle BackColor="#4B6C9E" ForeColor="White" Height="15px" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Action">
<HeaderStyle BackColor="#4B6C9E" ForeColor="White" />
<ItemTemplate>
<table style="margin-top: 5px">
<tr>
<td>
<asp:Button ID="btnright" runat="server" CommandName="moveright" Text=">" />
</td>
</tr>
<tr>
<td>
<asp:Button ID="btnallright" runat="server" CommandName="moveallright" Text=">>" />
</td>
</tr>
</table>
</ItemTemplate>
<FooterTemplate>
</FooterTemplate>
<FooterStyle BackColor="#4B6C9E" ForeColor="White" />
</asp:TemplateField>
</Columns>
</asp:GridView>
protected void viewgrid_RowCommand(object sender, GridViewCommandEventArgs e)
{
GridView grd = (GridView)sender;
if (e.CommandName == "moveright")
{
//string newRegionID = string.Empty;
GridViewRow gridrow = (GridViewRow)((Button)e.CommandSource).NamingContainer;
int index = gridrow.RowIndex;
//ListBox region = (ListBox)(gridrow.FindControl("listlocation"));
ListBox region = (ListBox)(viewgrid.Rows[index].FindControl("listlocation"));
List<ListItem> selectedregions = new List<ListItem>();
List<object> toRemove = new List<object>();
foreach (ListItem li in region.Items)
{
if (li.Selected)
{
selectedregions.Add(li);
listlocation2.Items.Add(li);
}
}
foreach (ListItem lll in selectedregions)
{
region.Items.Remove(lll);
}
}
if (e.CommandName == "moveallright")
{
lblmessage.Visible = false;
GridViewRow gridrow = (GridViewRow)((Button)e.CommandSource).NamingContainer;
int index = gridrow.RowIndex;
ListBox locationlist1 = (ListBox)(viewgrid.Rows[index].FindControl("listlocation"));
while (locationlist1.Items.Count != 0)
{
for (int i = 0; i < locationlist1.Items.Count; i++)
{
listlocation2.Items.Add(locationlist1.Items[i]);
locationlist1.Items.Remove(locationlist1.Items[i]);
}
}
}
}

can it possible calling inner repeater in nested-repeater, if possible then how?

I have nested Repeater. i am using 3 repeater. For calling(firing) the 1st repeater which is working fine and returning 100% result. But when i am calling(firing) 2nd repeater. it is not firing. I just want to know should i call 2nd repeater event if it is in nested format? Or i can not call. If i can call can u suggest how can i call that event?
<asp:UpdatePanel ID="RepeaterPanel" runat="server">
<ContentTemplate>
<div id="mydiv">
<asp:Repeater ID="RpterShareDetails" runat="server" onitemcommand="RpterShareDetails_ItemCommand">
<HeaderTemplate>
<table id="table1">
</HeaderTemplate>
<ItemTemplate>
<tr>
<td rowspan="2" align="center" class="message_repeater_panel_left">
<asp:Image ID="Image1" runat="server" ImageUrl="~/ShowImage.ashx" alt="" width="50" height="50" />
</td>
<td>
<embed src='<%# Eval("FilePath") %>' type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="150" height="150" runat="server" Visible='<%# IsVisible(Eval("UploadType"))%>'></embed>
<asp:ImageButton ID="ibtnHolder" runat="server" Width="130" Height="130" ImageUrl='<%# Eval("FilePath") %>' Visible='<%# NotVisible(Eval("UploadType"))%>' />
</td>
<td class="textTob">
<asp:Label ID="UserCommentLabel" runat="server" Text='<%# Eval("Comments") %>' />
</td>
</tr>
<tr>
<td valign="bottom"> User Keyword:
<asp:Label ID="UserKeywordLabel" runat="server" Text='<%# Eval("Keyword") %>' />
</td>
</tr>
<tr>
<td colspan="2">
<div class="message_repeater_links12">
<span>
<asp:LinkButton ID = "lnkLike" runat = "server" CommandName = "Like">Like</asp:LinkButton>
</span>
<span>
<asp:LinkButton ID="lnk_Comments" runat="server" CommandName="comments" CommandArgument='<%# Eval("Sniffid") %>'>Comments</asp:LinkButton></span>
<span>
<asp:LinkButton ID="lnk_ShowComments" runat="server" CommandName="Show" CommandArgument='<%# Eval("Sniffid") %>'>Show</asp:LinkButton></span>
<span>Share</span>
<asp:Panel ID="Add_Comments" runat="server" Width="90%" class="message_repeater_panel_left">
</asp:Panel>
<asp:Panel ID="Dis_comments" runat="server" Width="90%" class="message_repeater_panel_left">
</asp:Panel>
</div>
</td>
</tr>
<asp:TextBox ID="txt_comment" runat="server" TextMode="MultiLine" Width="300" Visible="false"></asp:TextBox>
<asp:UpdatePanel ID="RepeaterPanel" runat="server" >
<ContentTemplate>
<div style="background-color: #C0C0C0">
<asp:Repeater ID="Rbt_comments" runat="server" onitemcommand="Rbt_comments_ItemCommand1" >
<HeaderTemplate>
<table>
</HeaderTemplate>
<ItemTemplate>
<%--<div class="message_repeater_panel_left1" >--%>
<tr>
<td>
<span >
<img src="images/photo_sniff.jpg" width="25px" />
<%--<asp:Image ID = "imgCommentPhotos" runat = "server" ImageUrl = "~/AddCommentPhotos.ashx" Width = "25" Height = "25" />--%>
</span>
</td>
<td>
<span><asp:Label ID="UserCommentLabel" runat="server" Text='<%# Eval("Comments") %>' /></span>
</td>
</tr>
<%--</div>
<div class="message_repeater_links12"> --%>
<tr>
<td>
<span><asp:LinkButton ID = "lnkLike" runat = "server" CommandName = "SubLike">Like</asp:LinkButton></span>
</td>
<td>
<span><asp:LinkButton ID="lnk_Comments" runat="server" CommandName="Subcomments">Comments</asp:LinkButton></span>
</td>
<td>
<span><asp:LinkButton ID="lnk_ShowComments" runat="server" CommandName="SubShow">Show</asp:LinkButton></span>
</td>
<td>
<span>Share</span>
</td>
</tr>
<%--</div>--%>
<tr>
<td colspan="4">
<asp:TextBox ID = "txtComment" runat = "server" TextMode="MultiLine" Width="300" Visible = "false"></asp:TextBox>
<div class="message_repeater_panel_left1" ></div>
<div class="message_repeater_links12"></div>
</td>
</tr>
<ContentTemplate>
<div style="background-color: #C0C0C0">
<asp:Repeater ID="rptSubComments" runat="server">
<HeaderTemplate>
<table>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<span >
<img src="images/Santosh.jpg" width="25px" />
<%--<asp:Image ID = "imgCommentPhotos" runat = "server" ImageUrl = "~/AddCommentPhotos.ashx" Width = "25" Height = "25" />--%>
</span>
</td>
<td>
<span><asp:Label ID="lblUserSubComment" runat="server" Text='<%# Eval("Comments") %>' /></span>
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
</div>
</ContentTemplate>
</ItemTemplate>
<FooterTemplate></table></FooterTemplate>
</asp:Repeater>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</ItemTemplate>
<SeparatorTemplate>
<br />
</SeparatorTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
</div>
<br />
<br />
<uc1:CustomPagination ID="RepeaterCustomPagination" runat="server" />
</ContentTemplate>
</asp:UpdatePanel>
protected void Rbt_comments_ItemCommand1(object source, RepeaterCommandEventArgs e)
{
try
{
if (e.CommandName == "Subcomments")
{
}
}
catch (Exception ex)
{
}
}
protected void RpterShareDetails_ItemCommand(object source, RepeaterCommandEventArgs e)
{
try
{
if (e.CommandName == "Like")
{
Int32 UserId = Convert.ToInt32(Session["UserID"].ToString());
LikeShareDetails(UserId);
}
if (e.CommandName == "comments")
{
LinkButton btn = e.CommandSource as LinkButton;
if (btn != null)
{
TextBox txt = (TextBox)e.Item.FindControl("txt_comment");
txt.Visible = true;
txt.Attributes.Add("OnKeyPress", "isNumberKey(this,"+ e.CommandArgument.ToString() +")");
Panel Panel2 = (Panel)e.Item.FindControl("Add_Comments");
Literal lt = new Literal(); lt.Text = "<br />";
Panel2.Controls.Add(lt);
Panel2.Controls.Add(txt);
DataTable dt = new DataTable();
Repeater gv = (Repeater)e.Item.FindControl("Rbt_comments");
SqlConnection sqlCon = new SqlConnection();
sqlCon.ConnectionString = ConfigurationManager.ConnectionStrings["ISnifferDBConnectionString"].ConnectionString;
//sqlCon.ConnectionString = CommonUtil.GetConfigValue("ISnifferDBConnectionString");
string strSql = "select Comments from Comments where SniffId in ('" + e.CommandArgument.ToString() + "') order by CommentId desc";
SqlCommand sqlComd = new SqlCommand(strSql, sqlCon);
sqlCon.Open();
SqlDataAdapter sqlAdpt = new SqlDataAdapter();
sqlAdpt.SelectCommand = sqlComd;
sqlAdpt.Fill(dt);
int row = dt.Rows.Count;
if (row >= 1)
{
gv.DataSource = dt;
gv.DataBind();
}
else
{
dt.Rows.Add("No Comments");
gv.DataSource = dt;
gv.DataBind();
}
Panel Panel1 = (Panel)e.Item.FindControl("Dis_comments");
Panel1.Controls.Add(gv);
}
}
}
}

Open user control in ModalPopUpExtender when text box is clicked

I have few textboxes on one page and one user control. What I want is when user click in particular or when textbox gain a focus, it should open pop up. The user control contains a grid which is filled in load event. Now when user clicks on a button, the popup should get closed and textboxes the patent page should get filled with the values from the selected row.
How to do this?
Here is the code for my .aspx page and use control page.
Code for Parent page
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div>
<table class="style1" width="100%">
<tr>
<td width="20%">
ID</td>
<td width="60%">
<asp:TextBox ID="txtID" runat="server" ontextchanged="txtID_TextChanged"></asp:TextBox>
</td>
<td>
</td>
</tr>
<tr>
<td>
Name</td>
<td>
<asp:TextBox ID="txtName" runat="server" ontextchanged="txtName_TextChanged"></asp:TextBox>
</td>
<td>
</td>
</tr>
<tr>
<td>
HOD</td>
<td>
<asp:TextBox ID="txtHOD" runat="server"></asp:TextBox>
</td>
<td>
</td>
</tr>
<tr>
<td>
Email</td>
<td>
<asp:TextBox ID="txtEmail" runat="server"></asp:TextBox>
</td>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td>
<asp:Button ID="btnGet" runat="server" onclick="btnGet_Click"
Text="Get Values" />
</td>
<td>
</td>
</tr>
</table>
</div>
<UC:UserControl ID="UC1" runat="server" />
</form>
Parent page .aspx.cs
protected void Page_Load(object sender, EventArgs e)
{
if(Session["dtTable"] != null)
{
Hashtable Table = (Hashtable)Session["dtTable"];
txtID.Text = Table["ID"].ToString();
txtHOD.Text = Table["HOD"].ToString();
txtName.Text = Table["Name"].ToString();
txtEmail.Text = Table["Email"].ToString();
}
}
protected void txtID_TextChanged(object sender, EventArgs e)
{
UC1.Show();
Page.Controls.Add(UC1);
}
Code for User control .ascx page
<ContentTemplate>
<asp:Panel ID="DisplayPanel" runat="server">
<table class="style1">
<tr>
<td width="25%">
</td>
<td align="right">
</td>
<td width="25%">
</td>
</tr>
<tr>
<td>
</td>
<td>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
CellPadding="4" ForeColor="#333333" GridLines="None"
onrowcommand="GridView1_RowCommand">
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<Columns>
<asp:BoundField DataField="DeptId" HeaderText="ID"/>
<asp:BoundField DataField="Name" HeaderText="Name"/>
<asp:BoundField DataField="HeadName" HeaderText="HOD"/>
<asp:BoundField DataField="HeadEmail" HeaderText="Email"/>
<asp:TemplateField>
<HeaderTemplate>
Select
</HeaderTemplate>
<ItemTemplate>
<asp:Button ID="btnAdd" runat="server" Text="ADD" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<EditRowStyle BackColor="#999999" />
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#E9E7E2" />
<SortedAscendingHeaderStyle BackColor="#506C8C" />
<SortedDescendingCellStyle BackColor="#FFFDF8" />
<SortedDescendingHeaderStyle BackColor="#6F8DAE" />
</asp:GridView>
</td>
<td>
</td>
</tr>
</table>
Code for user control .ascx.cs page
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
SqlConnection oConnection = new SqlConnection("Data Source=websrv3;Initial Catalog=20110801_AcrosBackup;Persist Security Info=True;User ID=sa;Password=SQL#admin");
SqlCommand oCommand = new SqlCommand("select * from Department", oConnection);
SqlDataAdapter oAdapter = new SqlDataAdapter(oCommand);
DataTable dt = new DataTable();
oAdapter.Fill(dt);
GridView1.DataSource = dt;
GridView1.DataBind();
}
}
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
Hashtable dtTable = new Hashtable();
int intRowInd = ((GridViewRow)(((Button)e.CommandSource).NamingContainer)).RowIndex;
dtTable.Add("ID",GridView1.Rows[intRowInd].Cells[0].Text);
dtTable.Add("Name", GridView1.Rows[intRowInd].Cells[1].Text);
dtTable.Add("HOD", GridView1.Rows[intRowInd].Cells[2].Text);
dtTable.Add("Email", GridView1.Rows[intRowInd].Cells[3].Text);
Session.Add("dtTable", dtTable);
}
public void Show()
{
this.ModalPopupExtender1.Show();
}
</asp:Panel>
<asp:Button ID="fake" runat="server" Style="display:none" />
<cc1:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="fake" PopupControlID="DisplayPanel" BackgroundCssClass="overlay_style">
</cc1:ModalPopupExtender>
</ContentTemplate>
Add this onfocus attribute to your textbox.
onfocus="$find("<%= YourModalPopupExtenderID.ClientID %>").show();"

Resources