How to change submit button to update button - asp.net

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 + "");
}
}

Related

Image Button OnClick Event Not firing

Here Is the Code, when i try to fire the event in Browser it is not fired
<asp:Panel ID="StateDistrictGrid_pnl" runat="server">
<asp:GridView ID="User_grd" runat="server" DataKeyNames="VoterID" AutoGenerateColumns="False" AllowPaging="True">
<Columns>
<asp:TemplateField HeaderText="Edit">
<ItemTemplate>
<asp:ImageButton ID="Img_btn" ImageUrl="~/Images/52105-200.png" OnClick="Img_btn_Click" Height="20px" Width="30px" runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="ID" Visible="false" />
<asp:BoundField DataField="VoterName" HeaderText="Voter Name" SortExpression="VoterName" />
<asp:BoundField DataField="StateName" HeaderText="State Name" SortExpression="StateName" />
<asp:BoundField DataField="DistrictName" HeaderText="District Name" SortExpression="DistrictName" />
</Columns>
</asp:GridView>
<asp:Label ID="Lbl_Result" runat="server">
<asp:Button ID="BtnShowPopup" runat="server" Text="Edit" />
<asp:ModalPopupExtender ID="Show_mpe" runat="server" TargetControlID="BtnShowPopup" PopupControlID="PopUp_Pnl" CancelControlID="Btn_Cancel" BackgroundCssClass="textbox_radius"></asp:ModalPopupExtender>
<asp:Panel ID="PopUp_Pnl" runat="server" style = "display:none">
<asp:Label Font-Bold = "true" ID = "Details_lbl" runat = "server" Text = "Voter Details" ></asp:Label>
<br />
<table align = "center">
<tr>
<td>
<asp:Label ID = "ID_lbl" runat = "server" Text = "Voter ID" ></asp:Label>
</td>
<td>
<asp:TextBox ID="VoterID_txt" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Label ID = "Voter_lbl" runat = "server" Text = "Voter Name" ></asp:Label>
</td>
<td>
<asp:TextBox ID="VoterName_txt" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Label ID = "Statepnl_lbl" runat = "server" Text = "State Name" ></asp:Label>
</td>
<td>
<asp:TextBox ID="State_txt" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Label ID = "Districtpnl_lbl" runat = "server" Text = "District Name" ></asp:Label>
</td>
<td>
<asp:TextBox ID="District_txt" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Button ID="btnSave" runat="server" Text="Save" />
</td>
<td>
<asp:Button ID="Btn_Cancel" runat="server" Text="Cancel" />
</td>
</tr>
</table>
</asp:Panel>
</asp:Label>
</asp:Panel>
and the backend code is like this:
is thier any problem in In my Code please help thank you
protected void Img_btn_Click(object sender, ImageClickEventArgs e)
{
ImageButton Bt = sender as ImageButton;
GridViewRow GVRow = (GridViewRow)Bt.NamingContainer;
ID_lbl.Text = User_grd.DataKeys[GVRow.RowIndex].Value.ToString();
VoterName_txt.Text = GVRow.Cells[2].Text;
State_txt.Text = GVRow.Cells[3].Text;
District_txt.Text = GVRow.Cells[4].Text;
}
but when i run it the event is not Fired..What's the Problem?
Your issue is somehow the same that I encountered few months back. This might help you some way or another. try using LinkButton instead of Button...
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:gridview runat="server" id="GridView1" showfooter="true"
autogeneratecolumns="false" GridLines="None" CssClass="table1"
OnRowCreated="GridView1_RowCreated" BorderColor="#356600"
BorderStyle="Solid" >
<columns>
<asp:TemplateField HeaderText="Date" >
<ItemTemplate>
<asp:LinkButton ID="Date" runat="server"
CausesValidation="false" CommandName="Date_Select"
Text='<%#Eval("Date","{0:yyyy-MM-dd}") %>' onclick="Date_Click"
EnableTheming="False"></asp:LinkButton>
</ItemTemplate>
<EditItemTemplate>
</EditItemTemplate>
</asp:TemplateField>
<asp:boundfield datafield="Profit" headertext="Profit"
footerstyle-font-bold="true">
<FooterStyle Font-Bold="True"></FooterStyle>
</asp:boundfield>
</columns>
<HeaderStyle BackColor="#CEFF99" ForeColor="Black" BorderColor="#C1FF80"
BorderStyle="Solid" BorderWidth="1px"></HeaderStyle>
<RowStyle CssClass="td"></RowStyle>
</asp:gridview>
</ContentTemplate>
</asp:UpdatePanel>
protected void Date_Click(object sender, EventArgs e)
{
LinkButton Lnk = (LinkButton)sender;
Label1.Text = Lnk.Text; // This one works for me....
OdbcConnection con1 =
new OdbcConnection(ConfigurationManager
.ConnectionStrings["connect1"]
.ConnectionString);
OdbcCommand cmd = new OdbcCommand("select a.customer As Customer,a.mins as MIns,a.amount as Amount,a.profit as Profit from summarydatashort a,clientsrecord b where a.orig_clli=b.orig_clli and a.date='" + Label1.Text + "' and b.emplye='Ankit'", con1);
con1.Open();
OdbcDataAdapter da = new OdbcDataAdapter(cmd);
da.Fill(ds);
con1.Close();
GridView17.DataSource = ds;
GridView17.DataBind();
}

listview_onitemcommand is not firing

my code is
protected void ListView2_OnItemCommand(object sender, ListViewCommandEventArgs e)
{
if (String.Equals(e.CommandName, "forallow"))
{
string[] commandArgs = e.CommandArgument.ToString().Split(new char[] { ',' });
string scrapid = commandArgs[0];
string uid = commandArgs[1];
string imgname = commandArgs[2];
int cat = Convert.ToInt32(scrapid);
int sho = Convert.ToInt32(uid);
string query2 = "update request set status='allow' where request_id='" + cat + "'and shop_id=" + sho + ";update advertisement set imagename='" + imgname + "',shop_id='" + sho + "' where adver_id=" + cat;
cmd = new SqlCommand(query2, connection);
cmd.Connection.Open();
int rows = cmd.ExecuteNonQuery();
if (rows > 0)
{
Response.Write(#"<script language='javascript'>alert('permission granted');</script>");
}
cmd.Connection.Close();
string msgg = "insert into messages(message,shop_id) values('Permission is granted for category id ''" + cat + "' ,'" + sho + "')";
cmd = new SqlCommand(msgg, connection);
cmd.Connection.Open();
cmd.ExecuteNonQuery();
cmd.Connection.Close();
productfill();
}
}
and html code is
<asp:ListView ID="ListView2" runat="server" OnItemDeleting="ListView2_ItemDeleting" OnItemCommand="ListView2_OnItemCommand">
<LayoutTemplate>
<table runat="server" class="TableCSS">
<tr runat="server" class="TableHeader">
<td runat="server">Advertisement ID</td>
<td runat="server">Advertisement Plan</td>
<td runat="server">Shop ID</td>
<td runat="server">Permission</td>
</tr>
<tr id="ItemPlaceholder" runat="server">
</tr>
<tr runat="server" class="TablePager">
<td runat="server" colspan="3">
<asp:DataPager ID="DataPager1" runat="server">
<Fields>
<asp:NextPreviousPagerField
ButtonType="Button"
ShowFirstPageButton="true"
ShowPreviousPageButton="false"
ShowNextPageButton="true"
ButtonCssClass="PagerButtonCSS"
/>
<asp:NumericPagerField
NumericButtonCssClass="NumericButtonCSS"
NextPreviousButtonCssClass="NextPreviousButtonCSS"
CurrentPageLabelCssClass="CurrentPageLabelCSS"
/>
<asp:NextPreviousPagerField
ButtonType="Button"
ShowNextPageButton="false"
ShowLastPageButton="true"
ButtonCssClass="PagerButtonCSS"
/>
</Fields>
</asp:DataPager>
</td>
</tr>
</table>
</LayoutTemplate>
<EmptyDataTemplate>
<table runat="server"
style="background-color: #FFFFFF;border-collapse: collapse;border-color: #999999;border-style:none;border-width:1px;">
<tr>
<td>
NO RECORD FOUND.</td>
</tr>
</table>
</EmptyDataTemplate>
<ItemTemplate>
<tr class="TableData">
<td>
<asp:Label ID="Label2" runat="server" Text='<%#DataBinder.Eval(Container.DataItem,"request_id")%>'>
</asp:Label>
</td>
<td>
<asp:Label ID="lblcat" runat="server" Text='<%#DataBinder.Eval(Container.DataItem,"adver_plan")%>'>
</asp:Label>
</td>
<td>
<asp:Label ID="Label1" runat="server" Text='<%#DataBinder.Eval(Container.DataItem,"shop_id")%>'>
</asp:Label>
</td>
<td> <%-- ValidationGroup="cho" CommandArgument='<%#DataBinder.Eval(Container.DataItem,"request_id")+","+DataBinder.Eval(Container.DataItem,"shop_id")+","+DataBinder.Eval(Container.DataItem,"message")%>'--%>
<asp:Button ID="Button1" runat="server" Text="Allow" Width="45px" CommandName="forallow" ValidationGroup="cho" CommandArgument='<%#DataBinder.Eval(Container.DataItem,"request_id")+","+DataBinder.Eval(Container.DataItem,"shop_id")+","+DataBinder.Eval(Container.DataItem,"message")%>'/><asp:Button ID="Button2" runat="server" Text="Deny" Width="45px" ValidationGroup="2" CommandName="Delete" OnClientClick="return deleteConfirm();"/>
</td>
</tr>
</ItemTemplate>
<EditItemTemplate>
</EditItemTemplate>
</asp:ListView>
plz make this solve as soon as possible
Where is your OnClick event? What is going to make this event fire? If this is all of your code then it will never fire. Recheck your code and make sure you show it all to us.

Can a TargetControlID of a PopUp use the Button of a GridView?

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();

How to update gridview when upon click submit button?

I want to add booth detail into database, after user insert booth alias, select booth type and booth duration, next click submit button and the newly added record will appear in the gridview below the old records.
I know there are something missing in the code but I not sure what is the problem.
The client code:
<%# Page Language="VB" MasterPageFile="~/MasterPageAdmin.master" AutoEventWireup="false" CodeFile="addbooth.aspx.vb" Inherits="addbooth" title="Untitled Page" %>
<%# Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="ContentPlaceHolder2" runat="server"
contentplaceholderid="ContentPlaceHolder2">
<table class="style8" cellpadding="3">
<tr>
<td class="style9">Add New Booth</td>
<td> </td>
</tr>
<tr>
<td class="style9"> </td>
<td> </td>
</tr>
<tr>
<td class="style9">Event Title:</td>
<td>
<asp:SqlDataSource ID="SqlDataSourceEventTitle" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString1 %>" SelectCommand="SELECT DISTINCT [eventID], [eventTitle] FROM [eventinfo]">
</asp:SqlDataSource>
<asp:DropDownList ID="ddlEventTitle" runat="server" DataSourceID="SqlDataSourceEventTitle" DataTextField="eventTitle" DataValueField="eventID" Width="240px" AutoPostBack="True">
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="style9">Booth Alias:</td>
<td>
<asp:TextBox ID="txtBoothAlias" runat="server" Width="235px"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style9"> Booth Type:</td>
<td>
<asp:DropDownList ID="ddlBoothType" runat="server" Width="240px" AutoPostBack="True">
<asp:ListItem Value="7">8'x8'</asp:ListItem>
<asp:ListItem Value="10">9'x8'</asp:ListItem>
<asp:ListItem Value="11">12'x50'</asp:ListItem>
<asp:ListItem Value="12">16'x10'</asp:ListItem>
<asp:ListItem Value="13">20'x16'</asp:ListItem>
<asp:ListItem Value="15">32'x10'</asp:ListItem>
<asp:ListItem Value="17">32'x14.5'</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="style10" valign="top" colspan="2">Booth Duration:<br />
<font size="2">Tick to activate availability</font></td>
</tr>
<tr>
<td class="style10" valign="top" colspan="2" align="center">
<asp:Panel ID="Panel1" runat="server" Width="328px" Direction="LeftToRight" HorizontalAlign="Center">
<table cellpadding="5" class="style8">
<tr>
<td>
<asp:CheckBox ID="cbWeek1" runat="server" Text="Week 1" TextAlign="Left" OnCheckedChanged="cbWeek1_CheckedChanged" AutoPostBack="true"/>
</td>
<td>
<asp:CheckBox ID="cbWeek2" runat="server" Text="Week 2" TextAlign="Left" OnCheckedChanged="cbWeek2_CheckedChanged" AutoPostBack="true"/>
</td>
<td>
<asp:CheckBox ID="cbWeek3" runat="server" Text="Week 3" TextAlign="Left" OnCheckedChanged="cbWeek3_CheckedChanged" AutoPostBack="true"/>
</td>
<td>
<asp:CheckBox ID="cbWeek4" runat="server" Text="Week 4" TextAlign="Left" OnCheckedChanged="cbWeek4_CheckedChanged" AutoPostBack="true"/>
</td>
</tr>
<tr>
<td>
<asp:CheckBox ID="cbWeek5" runat="server" Text="Week 5" TextAlign="Left" OnCheckedChanged="cbWeek5_CheckedChanged" AutoPostBack="true"/>
</td>
<td>
<asp:CheckBox ID="cbWeek6" runat="server" Text="Week 6" TextAlign="Left" OnCheckedChanged="cbWeek6_CheckedChanged" AutoPostBack="true"/>
</td>
<td>
<asp:CheckBox ID="cbWeek7" runat="server" Text="Week 7" TextAlign="Left" OnCheckedChanged="cbWeek7_CheckedChanged" AutoPostBack="true"/>
</td>
<td>
<asp:CheckBox ID="cbWeek8" runat="server" Text="Week 8" TextAlign="Left" OnCheckedChanged="cbWeek8_CheckedChanged" AutoPostBack="true"/>
</td>
</tr>
</table>
</asp:Panel>
<asp:RoundedCornersExtender ID="Panel1_RoundedCornersExtender"runat="server" Enabled="True" TargetControlID="Panel1" BorderColor="CadetBlue" Color="ButtonFace">
</asp:RoundedCornersExtender>
</td>
</tr>
<tr>
<td class="style11">
</td>
<td class="style11">
<asp:Button ID="ButtonAddNewBooth" runat="server" Text="Add New Booth" Height="50px" />
</td>
</tr>
<tr>
<td class="style9"> </td>
<td> </td>
</tr>
<tr>
<td class="style9" colspan="2">
<asp:GridView ID="GridViewBoothAdded" runat="server" AutoGenerateColumns="False" CellPadding="4" DataSourceID="SqlDataSourceBoothAdded" Font-Size="Small" ForeColor="#333333" GridLines="None" AllowPaging="True" PageSize="5" Visible="False">
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<Columns>
<asp:BoundField DataField="boothAlias" HeaderText="Booth Alias" SortExpression="boothAlias" />
<asp:BoundField DataField="week1" HeaderText="week1" SortExpression="week1" />
<asp:BoundField DataField="week2" HeaderText="week2" SortExpression="week2" />
<asp:BoundField DataField="week3" HeaderText="week3" SortExpression="week3" />
<asp:BoundField DataField="week4" HeaderText="week4" SortExpression="week4" />
<asp:BoundField DataField="week5" HeaderText="week5" SortExpression="week5" />
<asp:BoundField DataField="week6" HeaderText="week6" SortExpression="week6" />
<asp:BoundField DataField="week7" HeaderText="week7" SortExpression="week7" />
<asp:BoundField DataField="week8" HeaderText="week8" SortExpression="week8" />
</Columns>
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<EmptyDataTemplate>
No booth record
</EmptyDataTemplate>
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" Font-Size="Small" ForeColor="White" />
<EditRowStyle BackColor="#999999" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
</asp:GridView>
<asp:RoundedCornersExtender ID="GridViewBoothAdded_RoundedCornersExtender" runat="server" Enabled="True" TargetControlID="GridViewBoothAdded">
</asp:RoundedCornersExtender>
<asp:SqlDataSource ID="SqlDataSourceBoothAdded" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString1 %>"
SelectCommand="SELECT [week1], [week2], [week3], [week4], [week5], [week6], [week7], [week8], [eventID], [boothAlias], [eventTitle] FROM [booth_eventinfo] WHERE ([eventID] = #eventID)">
<SelectParameters>
<asp:ControlParameter ControlID="ddlEventTitle" Name="eventID" PropertyName="SelectedValue" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
</td>
</tr>
</table>
server code:
Imports System
Imports System.Data
Imports System.Data.SqlClient
Imports System.Threading
Partial Class addbooth
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
GridViewBoothAdded.Visible = True
End Sub
Protected Sub ButtonAddNewBooth_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ButtonAddNewBooth.Click
Dim connString As String = ConfigurationManager.ConnectionStrings("ConnectionString1").ConnectionString
'"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\eventdb.mdf;Integrated Security=True;User Instance=True"
Dim con As SqlConnection = New SqlConnection(connString)
Dim cmdQuery As String = "INSERT INTO booth(eventID,boothAlias,boothType,week1,week2,week3,week4,week5,week6,week7,week8) VALUES (#eventID,#boothAlias,#boothType,#week1,#week2,#week3,#week4,#week5,#week6,#week7,#week8)"
Dim cmd = New SqlCommand(cmdQuery)
cmd.Connection = con
cmd.CommandType = CommandType.Text
con.Open()
cmd.Parameters.AddWithValue("#eventID", ddlEventTitle.SelectedValue)
cmd.Parameters.AddWithValue("#boothAlias", txtBoothAlias.Text)
cmd.Parameters.AddWithValue("#boothType", ddlBoothType.SelectedValue)
If (cbWeek1.Checked = True) Then
cmd.Parameters.AddWithValue("#week1", "1")
Else
cmd.Parameters.AddWithValue("#week1", "0")
End If
If (cbWeek2.Checked = True) Then
cmd.Parameters.AddWithValue("#week2", "1")
Else
cmd.Parameters.AddWithValue("#week2", "0")
End If
If (cbWeek3.Checked = True) Then
cmd.Parameters.AddWithValue("#week3", "1")
Else
cmd.Parameters.AddWithValue("#week3", "0")
End If
If (cbWeek4.Checked = True) Then
cmd.Parameters.AddWithValue("#week4", "1")
Else
cmd.Parameters.AddWithValue("#week4", "0")
End If
If (cbWeek5.Checked = True) Then
cmd.Parameters.AddWithValue("#week5", "1")
Else
cmd.Parameters.AddWithValue("#week5", "0")
End If
If (cbWeek6.Checked = True) Then
cmd.Parameters.AddWithValue("#week6", "1")
Else
cmd.Parameters.AddWithValue("#week6", "0")
End If
If (cbWeek7.Checked = True) Then
cmd.Parameters.AddWithValue("#week7", "1")
Else
cmd.Parameters.AddWithValue("#week7", "0")
End If
If (cbWeek8.Checked = True) Then
cmd.Parameters.AddWithValue("#week8", "1")
Else
cmd.Parameters.AddWithValue("#week8", "0")
End If
GridViewBoothAdded.Visible = True
Can you move you GridView Data Binding Code to code behind file Page_Load Method & call the same code at the end of your ButtonAddNewBooth_Click event. That will serve your purpose.
Link: GridView.DataBind
I see in your ButtonAddNewBooth_Click method you are missing the ExecuteSql() for the sqlcommand and gridview bind code
After adding parameters to cmd add the following two lines one for executing the insert and the other for rebinding the grid
cmd.ExecuteSql()
GridViewBoothAdded.DataBind()

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