HyperLink string formating on a repeater - c#

i need help building a dynamic URL.
I have a working asp:HyperLinkField on a GridView, but you can't use it on a reater. i can only use asp:HyperLink.
This is the working one:
<asp:HyperLinkField Text="Select" DataNavigateUrlFormatString="~/Products/Details?ProductID={0}" DataNavigateUrlFields="ProductID" />
And this the one that doesn't
<asp:HyperLink runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "ProductName") %>' NavigateUrl='~/Products/Details?ProductID=BK100' />
I am using it inside a asp:Repeater. thank you.

Hop it helps
<asp:HyperLink ID="HyperLink1" runat=server NavigateUrl='<%# DataBinder.Eval(Container.DataItem, "YourField", "Desc.aspx?query={0}") %>'> <%# DataBinder.Eval(Container.DataItem, "YourFieldForText") %>' </asp:HyperLink>

If you don't mind using C# code to bind..
.aspx
<h2>Grid View</h2>
<br />
<asp:GridView ID="gv" runat="server" AutoGenerateColumns="false">
<Columns>
<asp:HyperLinkField HeaderText="Link" Text="Select"
DataNavigateUrlFormatString="~/Products/Details?ProductID={0}"
DataNavigateUrlFields="ProductID" />
</Columns>
</asp:GridView>
<br />
<br />
<h2>Repeater</h2>
<br />
<asp:Repeater ID="r" runat="server" OnItemDataBound="r_ItemDataBound">
<HeaderTemplate>
<table style="padding: 0px; border-spacing: 0px;">
<tr>
<td style="border: 1px solid #ccc; text-align: center;">
<asp:Label ID="lblTitle" runat="server" Text="Link"
Font-Bold="true"></asp:Label>
</td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td style="border: 1px solid #ccc; border-top: 0px;">
<asp:Label ID="lblHidden" runat="server"
Text='<%# Eval("ProductID") %>' Visible="false"></asp:Label>
<asp:HyperLink ID="hl" runat="server"
Text='<%# Eval("ProductName") %>'></asp:HyperLink>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
.cs
protected void Page_Load(object sender, EventArgs e)
{
// Check
if (!IsPostBack)
{
// Variable
string[] productName = { "SharePoint", "CRM", "SiteCore", "Silver Light" };
DataTable dt = new DataTable();
dt.Columns.Add("ProductID");
dt.Columns.Add("ProductName");
for (int i = 0; i < productName.Length; i++)
dt.Rows.Add((i + 1) + "", productName[i]);
// Bind Grid View
gv.DataSource = dt;
gv.DataBind();
// Bind Repeater
r.DataSource = dt;
r.DataBind();
}
}
protected void r_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
// Variable
string url = "/Products/Details?ProductID={0}";
// Find Control
HyperLink hl = e.Item.FindControl("hl") as HyperLink;
Label lblHidden = e.Item.FindControl("lblHidden") as Label;
// Check
if (hl != null && lblHidden != null)
{
// Set Navigation Url
url = string.Format(url, lblHidden.Text.Trim());
hl.NavigateUrl = url;
}
}
}

You can try this
<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%# "~/Products/Details?ProductID="+Eval("ProductID") %>'> <%# Eval("ProductName") %> </asp:HyperLink>

Related

How do i pass a command argument of a button in Data List to another page?

Actually i am trying to redirect command argument of a button present in a data list to another page. I am using Request.QueryString method to access the command argument on another page with the help of command name of the button. Please help me with it...
this is code of button present inside Data List
<asp:Button ID="Button1" runat="server" Text="Read" CommandArgument='<%# Eval("id")%>' OnClick="Button1_Click" CommandName="content"/>
this is code present in DataList Item command function
protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e)
{
Response.Redirect("content.aspx?content=" +e.CommandArgument.ToString());
}
this is the onclick function code
protected void Button1_Click(object sender, EventArgs e)
{
Response.Redirect("content.aspx");
}
this is the code on another page(content.aspx)
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
String id = Request.QueryString["content"];
Label1.Text = id;
}
}
this is entire datalist code
<asp:DataList ID="DataList1" runat="server" DataKeyField="Id" DataSourceID="SqlDataSource1" Height="657px" RepeatColumns="4" RepeatDirection="Horizontal" Width="1248px" OnItemCommand="DataList1_ItemCommand" OnItemDataBound="DataList1_ItemDataBound">
<FooterStyle BackColor="White" ForeColor="#000066" />
<HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" />
<ItemStyle ForeColor="#000066" />
<ItemTemplate>
<table class="auto-style2">
<tr>
<td style="text-align: center">
<asp:Label ID="Label2" runat="server" Text='<%# Eval("name") %>'></asp:Label>
<asp:Label ID="Label4" runat="server" Text='<%# Eval("Id") %>' Visible="False"></asp:Label>
</td>
</tr>
<tr>
<td style="text-align: center">
<asp:Image ID="Image2" runat="server" Height="250px" ImageUrl='<%# Eval("image") %>' Width="250px" />
</td>
</tr>
<tr>
<td style="text-align: center">
<asp:Label ID="Label3" runat="server" Text="Label"></asp:Label>
<br />
<asp:ImageButton ID="ImageButton1" runat="server" CommandName="addtofav" CommandArgument='<%# Eval("id")%>' Height="30px" Width="20px" />
</td>
</tr>
<tr>
<td style="text-align: center">
<asp:Button ID="Button1" runat="server" Text="Read" CommandArgument='<%# Eval("id")%>' OnClick="Button1_Click" CommandName="content"/>
</td>
</tr>
</table
<br />
<br />
</ItemTemplate>
<SelectedItemStyle BackColor="#669999" Font-Bold="True" ForeColor="White" />
it does redirect to another page(content.aspx) but the label does not show the querystring text.
Try updating the DataList1_ItemCommand event to this:
protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e)
{
if (e.CommandName == "content")
{
Response.Redirect("content.aspx?content=" +e.CommandArgument.ToString());
}
}
also make sure you are checking IsPostBack in Page_Load method of this page code behind.
Yes i got the desired output. Actually i was also using another button to redirect to a diiferent page in DataList1_ItemCommand function. So i just needed to seperate the Response.redirects of the 2 buttons by putting them in if loop.
protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e)
{
if (e.CommandName == "content")
{
Response.Redirect("content.aspx?content="+e.CommandArgument.ToString());
}
if (e.CommandName == "addtofav")
{
Response.Redirect("sortbyAZ.aspx?addtofav=" + e.CommandArgument.ToString());
}
}
Thanks You everybody for helping me out with this one
I think you are not casting the Request.QueryString["content"] to string format, try this
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
String id = Request.QueryString["content"];
Label1.Text = id;
}
}
You can find all information you need in this tutorial. from #microsoft msdn
Best of luck
<%# Page Language="C#" AutoEventWireup="True" %>
<%# Import Namespace="System.Data" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>DataList Select Example</title>
<script runat="server">
ICollection CreateDataSource()
{
// Create sample data for the DataList control.
DataTable dt = new DataTable();
DataRow dr;
// Define the columns of the table.
dt.Columns.Add(new DataColumn("Item", typeof(Int32)));
dt.Columns.Add(new DataColumn("Qty", typeof(Int32)));
dt.Columns.Add(new DataColumn("Price", typeof(double)));
// Populate the table with sample values.
for (int i = 0; i < 9; i++)
{
dr = dt.NewRow();
dr[0] = i;
dr[1] = i * 2;
dr[2] = 1.23 * (i + 1);
dt.Rows.Add(dr);
}
DataView dv = new DataView(dt);
return dv;
}
void Page_Load(Object sender, EventArgs e)
{
// Load sample data only once, when the page is first loaded.
if (!IsPostBack)
{
ItemsList.DataSource = CreateDataSource();
ItemsList.DataBind();
}
}
void Item_Command(Object sender, DataListCommandEventArgs e)
{
// Set the SelectedIndex property to select an item in the DataList.
ItemsList.SelectedIndex = e.Item.ItemIndex;
// Rebind the data source to the DataList to refresh the control.
ItemsList.DataSource = CreateDataSource();
ItemsList.DataBind();
}
</script>
</head>
<body>
<form id="form1" runat="server">
<h3>DataList Select Example</h3>
Click <b>Select</b> to select an item.
<br /><br />
<asp:DataList id="ItemsList"
GridLines="Both"
CellPadding="3"
CellSpacing="0"
OnItemCommand="Item_Command"
runat="server">
<HeaderStyle BackColor="#aaaadd">
</HeaderStyle>
<AlternatingItemStyle BackColor="Gainsboro">
</AlternatingItemStyle>
<SelectedItemStyle BackColor="Yellow">
</SelectedItemStyle>
<HeaderTemplate>
Items
</HeaderTemplate>
<ItemTemplate>
<asp:LinkButton id="SelectButton"
Text="Select"
CommandName="Select"
runat="server"/>
Item <%# DataBinder.Eval(Container.DataItem, "Item") %>
</ItemTemplate>
<SelectedItemTemplate>
Item:
<asp:Label id="ItemLabel"
Text='<%# DataBinder.Eval(Container.DataItem, "Item") %>'
runat="server"/>
<br />
Quantity:
<asp:Label id="QtyLabel"
Text='<%# DataBinder.Eval(Container.DataItem, "Qty") %>'
runat="server"/>
<br />
Price:
<asp:Label id="PriceLabel"
Text='<%# DataBinder.Eval(Container.DataItem, "Price", "{0:c}")
%>'
runat="server"/>
</SelectedItemTemplate>
</asp:DataList>
</form>
</body>
</html>
By the way I think you don't need define Button Click event. Already defined path with variable. Just convert button to Link Button and remove Button Click Event

Find the selected value of a RadioButton inside a Lightbox that is inside a Repeater

I have a Repeater that contains a link labeled "Change Membership" that when clicked opens a lightbox with a radiobuttonlist and a button. When the button in the lightbox is clicked I have a callback event where I need to find the selected value of the radiobutton list first here is the repeater:
<script language="JavaScript" type="text/javascript">
function CreateBox(id) {
$(document).ready(function () {
$("#lnk" + id).fancybox({
'closeBtn': true,
helpers: {
overlay: { closeClick: false }
}
});
});
}
</script>
Head
Body
<asp:Repeater ID="repProspects" runat="server" OnItemDataBound="repProspects_ItemDataBound">
<ItemTemplate>
<asp:HiddenField ID="hfRequestID" runat="server" Value='<%# DataBinder.Eval(Container, "DataItem.RequestID") %>' />
<asp:HiddenField ID="hfRecruiterNumber" runat="server" Value='<%# DataBinder.Eval(Container, "DataItem.RecruiterCardNumber") %>' />
<asp:HiddenField ID="hfCompanyID" runat="server" Value='<%# DataBinder.Eval(Container, "DataItem.CompanyID") %>' />
<asp:HiddenField ID="hfMemberType" runat="server" Value='<%# DataBinder.Eval(Container, "DataItem.MemberType") %>' />
<asp:HiddenField ID="hfLifeDuesAmount" runat="server" Value='<%# DataBinder.Eval(Container, "DataItem.Dues") %>' />
<asp:HiddenField ID="hfDerivedAnnualDues" runat="server" />
<asp:HiddenField ID="hfDerivedInstallments" runat="server" />
<asp:HiddenField ID="hfRblSelectedValue" runat="server" />
<asp:HiddenField ID="hfSetMemberType" ClientIDMode="Static" runat="server" />
<asp:HiddenField ID="hfState" runat="server" Value='<%# DataBinder.Eval(Container, "DataItem.HomeState") %>' />
<asp:HiddenField ID="hfCountry" runat="server" Value='<%# DataBinder.Eval(Container, "DataItem.HomeCountry") %>' />
<asp:HiddenField ID="hfBirthday" runat="server" Value='<%# DataBinder.Eval(Container, "DataItem.Birthday") %>' />
<div id='h<%# DataBinder.Eval(Container, "DataItem.ID") %>' class="header" onclick='ToggleDisplay(<%# DataBinder.Eval(Container, "DataItem.ID") %>);'>
<img id="img<%# DataBinder.Eval(Container, "DataItem.ID") %>" alt="" src="../images/plusIconSmaller.png" />
<%# DataBinder.Eval(Container, "DataItem.FirstName")%>
<% if (DataBinder.GetDataItem("DataItem.MiddleName") != "")
{ %>
<%# DataBinder.Eval(Container, "DataItem.MiddleName")%>
<% } %>
<%# DataBinder.Eval(Container, "DataItem.LastName")%>
<% if (DataBinder.GetDataItem("DataItem.Suffix") != "")
{ %>
<%# DataBinder.Eval(Container, "DataItem.Suffix")%>
<% } %>
(<%# DataBinder.Eval(Container, "DataItem.CurrentStatus")%>, <%# DataBinder.Eval(Container, "DataItem.BranchOfService")%>)
<asp:Label ID="lblRecruitedBy" runat="server"></asp:Label>
<%# Convert.ToDateTime(DataBinder.Eval(Container, "DataItem.DateCreated")).ToShortDateString()%>
</div>
<div id='reqid<%# DataBinder.Eval(Container, "DataItem.RequestID") %>'></div>
<div id='d<%# DataBinder.Eval(Container, "DataItem.ID") %>' class="details">
<table width="100%">
<tr>
<td valign="top" width="25%"><u><b>Address</b></u><br />
<%# DataBinder.Eval(Container, "DataItem.HomeAddressLine1")%><br />
<%# DataBinder.Eval(Container, "DataItem.HomeCity")%>, <%# DataBinder.Eval(Container, "DataItem.HomeState")%> <%# DataBinder.Eval(Container, "DataItem.HomeZipCode")%><br />
<%# DataBinder.Eval(Container, "DataItem.HomeCountry")%></td>
<td valign="top" width="20%"><u><b>Qualifying Service</b></u><br />
<asp:Label ID="lblServiceInfo" runat="server"></asp:Label></td>
<td valign="top" width="20%"><u><b>Contact Info</b></u><br />
<% if (DataBinder.GetDataItem("DataItem.Phone") != "")
{ %>
<%# FormatPhone(DataBinder.Eval(Container, "DataItem.Phone").ToString()) %>
<% } %>
<asp:Label ID="lblMemberPhone" runat="server"></asp:Label>
<%# DataBinder.Eval(Container, "DataItem.Email")%><br />
Birthday: <%# Convert.ToDateTime(DataBinder.Eval(Container, "DataItem.Birthday")).ToShortDateString()%></td>
<td valign="top" width="20%"><u><b>Membership</b></u><br />
<%# DataBinder.Eval(Container, "DataItem.MemberType")%><br />
$<asp:Label ID="lblDuesAmount" runat="server"></asp:Label>
<br />
<a href='#ChgMemType<%# DataBinder.Eval(Container, "DataItem.ID") %>' onclick='CreateBox(<%# DataBinder.Eval(Container, "DataItem.ID") %>);' id='lnk<%# DataBinder.Eval(Container, "DataItem.ID") %>' >Change Membership</a>
</td>
<td valign="top" align="center">
<asp:Button ID="lnkApprove" Style="border: 1px solid black; border-radius: 7px; padding: 5px; cursor: pointer; background-color: #990000; width: 130px; color: white; font-weight: bold" Text="Approve & Pay" runat="server" CommandArgument='<%# DataBinder.Eval(Container, "DataItem.ID") %>' OnClientClick="return confirm('Are you sure you want to approve this member application?');" OnCommand="lnkApprove_Click"></asp:Button><br />
<br />
<asp:Button ID="lnkReject" Style="border: 1px solid black; border-radius: 7px; padding: 5px; cursor: pointer; background-color: #990000; width: 130px; color: white; font-weight: bold" Text="Reject" runat="server" CommandArgument='<%# DataBinder.Eval(Container, "DataItem.ID") %>' OnClientClick="return confirm('Are you sure you want to reject this member applictation?');" OnCommand="lnkReject_Click"></asp:Button></td>
</tr>
</table>
</div>
<div id='ChgMemType<%# DataBinder.Eval(Container, "DataItem.ID") %>' style="display: none; width:400px; text-align: left">
<h3>Change Membership Type </h3>
<p>Please select the membership type below:</p>
<input id='hfChangedMemberType' value="<%# DataBinder.Eval(Container, "DataItem.ID") %>" type="hidden" />
<div id="RadioDiv">
<asp:RadioButtonList ID="_rblMemberTypes" runat="server">
<asp:ListItem Text="Annual" Value="Annual">Annual</asp:ListItem>
<asp:ListItem Text="Life" Value="Life">Life</asp:ListItem>
<asp:ListItem Text="Installment" Value="Installment">Installment</asp:ListItem>
</asp:RadioButtonList>
</div>
<asp:LinkButton ID="lbSetMemType" EnableViewState="true" CommandArgument='<%# DataBinder.Eval(Container, "DataItem.RequestID") %>' OnCommand="lbSetMemType_Command" CssClass="button" runat="server">Save</asp:LinkButton>
</div>
</ItemTemplate>
</asp:Repeater>
Next is the code behind event when the Save button is clicked:
protected void lbSetMemType_Command(object sender, CommandEventArgs e)
{
decimal dDuesAmount = 0;
bool bSuccess = false;
int iRequestID = Convert.ToInt32(e.CommandArgument);
string sMemType = "";
HiddenField hfDerivedAnnualDues;
HiddenField hfDerivedInstallments;
HiddenField hfLifeDuesAmount;
HiddenField hfSetMemberType;
foreach (RepeaterItem item in repProspects.Items)
{
// Checking the item is a data item
if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem)
{
var reqid = item.FindControl("hfRequestID") as HiddenField;
if (Convert.ToInt32(reqid.Value) == iRequestID) {
var rdbList = item.FindControl("_rblMemberTypes") as RadioButtonList;
if (rdbList != null)
{
foreach (ListItem li in rdbList.Items)
{
if (li.Selected == true)
{
sMemType = li.Text;
}
}
}
// Get the selected value
hfSetMemberType = item.FindControl("hfRblSelectedValue") as HiddenField;
sMemType = rdbList.SelectedValue;
// sMemType = hfSetMemberType.Value;
hfDerivedAnnualDues = item.FindControl("hfDerivedAnnualDues") as HiddenField;
hfDerivedInstallments = item.FindControl("hfDerivedInstallments") as HiddenField;
hfLifeDuesAmount = item.FindControl("hfLifeDuesAmount") as HiddenField;
}
}
}
switch (sMemType)
{
case "Annual":
{
//dDuesAmount = Convert.ToDecimal(hfDerivedAnnualDues.Value);
break;
}
case "Life":
{
//dDuesAmount = Convert.ToDecimal(hfLifeDuesAmount.Value);
break;
}
case "Installments":
{
// dDuesAmount = Convert.ToDecimal(hfDerivedInstallments.Value);
break;
}
default:
{
//dDuesAmount = Convert.ToDecimal(hfDerivedAnnualDues.Value);
break;
}
}
bSuccess = logicManager.UpdateNewMemberAppMemType(iRequestID, sMemType, dDuesAmount);
}
I can set breakpoints and I can see the values in the hiddenfields are correct however I can't get the right clicked value on this statement:
sMemType = rdbList.SelectedValue;
I get the initial value but not the user clicked value?
First, you're missing OnItemCommand="lbSetMemType_Command" in your actual code.
Also, iterating through your repeater by hand will give you poor performance result, especially if you're looking for just the value of a radiobutton.
Now, lets do a MCVE example together. According to your code, you're trying to build a RadioButtonList inside a Repeater, with a LinkButton who use the radio's button value. In our case, let's just print the value of said choosen button in a label, proving our case.
MCVE.aspx
<asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent">
<asp:Repeater ID="rptTest" runat="server" OnItemCommand="rptTest_ItemCommand">
<ItemTemplate>
<asp:RadioButtonList ID="rdlTest" runat="server">
<asp:ListItem Text="Annual" Value="Annual"></asp:ListItem>
<asp:ListItem Text="Life" Value="Life"></asp:ListItem>
<asp:ListItem Text="Installment" Value="Installment"></asp:ListItem>
</asp:RadioButtonList>
<asp:LinkButton runat="server" ID="lbValidationTest" OnClick="lbValidationTest_Click" runat="server" >Fetch Value</asp:LinkButton>
</ItemTemplate>
</asp:Repeater>
<asp:Label runat="server" ID="lblViewResult"></asp:Label>
</asp:Content>
I'm using the default masterpage when you create a new project on VS. It really doesnt matter here
And the codebehind
MCVE.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WebApplication
{
public partial class MCVE: Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
List<int> uselessData = new List<int>(new int[] { 1, 2 });
this.rptTest.DataSource = uselessData;
this.rptTest.DataBind();
}
}
protected void rptTest_ItemCommand(object source, RepeaterCommandEventArgs e)
{
RadioButtonList list = (RadioButtonList)e.Item.FindControl("rdlTest");
this.lblViewResult.Text = list.SelectedValue;
}
}
}
After some tries, we clearly see that this is not working as intended. There is in fact some known issues between the Repeater & the RadioButtonListforbidding us to do just that.
So, what to do now ? We have plenty of solutions, we can for example use javascript to get and set our values in a hidden field ; we could iterate through or entire repeater tree and check every button or even use the CommandArgument to locate the RadioButtonList's index and fetch it in codebehind.
Let's implement the javascript solution. We are going to inject the value of our index in a hidden field present in the repeater. I think its better to treat this behaviour client side rather than server-side, but I could be mistaken and would love some output on this.
So let's add a very dirty javascript code to our view
MCVE.aspx New Version
<asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent">
<asp:Repeater ID="rptTest" runat="server" OnItemCommand="rptTest_ItemCommand">
<ItemTemplate>
<div>
<asp:HiddenField runat="server" ID="hfSelectedValue" />
<asp:RadioButtonList ID="rdlTest" runat="server" >
<asp:ListItem Text="Annual" Value="Annual" onclick="QuickAndDirtyHiddenSetDontUseItInProd(this)"></asp:ListItem>
<asp:ListItem Text="Life" Value="Life" onclick="QuickAndDirtyHiddenSetDontUseItInProd(this)"></asp:ListItem>
<asp:ListItem Text="Installment" Value="Installment" onclick="QuickAndDirtyHiddenSetDontUseItInProd(this)"></asp:ListItem>
</asp:RadioButtonList>
<asp:LinkButton runat="server" ID="lbValidationTest" runat="server" UserSubmitBehavior="true" >Fetch Value</asp:LinkButton>
</div>
</ItemTemplate>
</asp:Repeater>
<asp:Label runat="server" ID="lblViewResult"></asp:Label>
<script>
function QuickAndDirtyHiddenSetDontUseItInProd(data) {
$(data).parent().parent().parent().parent().siblings("input[name*=hfSelectedValue]").val(data.value);
}
</script>
</asp:Content>
We just changed 3 things. We're going to track a hidden field for each radiobuttonlist we're going to create, we added a script to change the value of said hidden field and linked the two with the onclic.
Now, on our codebehind, we just have to track the hidden field grouped with the click on the ButtonLink (ie, in the same RepeaterItem) and we're good to go.
MCVE.aspx.cs New Version
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WebApplication
{
public partial class MCVE: Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
List<int> uselessData = new List<int>(new int[] { 1, 2 });
this.rptTest.DataSource = uselessData;
this.rptTest.DataBind();
}
}
protected void rptTest_ItemCommand(object source, RepeaterCommandEventArgs e)
{
HiddenField hiddenField = (HiddenField)e.Item.FindControl("hfSelectedValue");
this.lblViewResult.Text = hiddenField.Value;
}
}
}
Pretty Self-explanatory, we just find the hidden field in our repeater, and we use it to fill the label.

How can use FindControl in the OnRowCommand of GridView?

I am trying to use findcontrol TextBox in RowCommand of the gridview.
But Error Object reference not set to an instance of an object.
Help me please.
Design
<asp:GridView ID="gvMaster" runat="server" AllowPaging="true" AutoGenerateColumns="False" OnRowCommand="gvMaster_RowCommand" Width="100%">
<Columns>
<asp:TemplateField HeaderText="">
<ItemTemplate>
<asp:ImageButton ID="ibtnEdit" runat="server" CommandName="edit" ImageUrl="~/images/edit.gif" ToolTip="Insert/Edit" />
</ItemTemplate>
<EditItemTemplate>
<table>
<tr>
<td nowrap="nowrap">
<asp:ImageButton ID="ibtnSave" runat="server" CommandName="update" ImageUrl="~/images/icon-floppy.gif" ToolTip="Save" />
</td>
<td nowrap="nowrap">
<asp:ImageButton ID="ibtnCancel" runat="server" CommandName="cancel" ImageUrl="~/images/icon-cancel.gif" ToolTip="Cancel" />
</td>
</tr>
</table>
</EditItemTemplate>
<ItemStyle HorizontalAlign="Center" Width="30px" />
<HeaderStyle HorizontalAlign="Center" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Effective Date">
<ItemTemplate>
<asp:Label ID="lblEffectiveDate" runat="server" Text='<%# String.Format("{0:dd/MM/yyyy}", Eval("eff_date")) %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<table>
<tr>
<td nowrap="nowrap">
<asp:TextBox ID="txtEffDate2" runat="server" MaxLength="10" Text='<%# String.Format("{0:dd/MM/yyyy}", Eval("eff_date")) %>'
Width="70px" Style="text-align: center"></asp:TextBox>
</td>
</tr>
</table>
</EditItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
Code BeHind:
protected void gvMaster_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName.ToUpper().Equals("SELECT"))
{
}
else if (e.CommandName.ToUpper().Equals("EDIT"))
{
string cmdNmEdit = e.CommandName;
object cmdSrcEdit = e.CommandSource;
GridViewRow gvMaster = (GridViewRow)(((Control)e.CommandSource).NamingContainer);
TextBox txtEffDate2 = gvMaster.FindControl("MyTextBoxId") as TextBox;
txtEffDate2.Text = DateTime.Now.ToString("DD/MM/yyyy"); //<------ Error This Line
}
}
How can use FindControl in the OnRowCommand of GridView?
Thanks in advance. ;)
The CommandArgument contains the row-index by default. That's why this works:
protected void gvMaster_RowCommand(object sender, GridViewCommandEventArgs e)
{
int rowIndex = Convert.ToInt32(e.CommandArgument);
GridView grid = (GridView) sender;
GridViewRow row = grid.Rows[rowIndex];
// now you can use row.FindControl
}

Copy a ListView and show it on a new page

I am trying to copy a ListView from one class to another and show that ListView on a new aspx page. What I am doing is I am selecting certain values from the first ListView and only those items will be shown on a new page. However, I can't figure out how to show the ListView on a new page because I am used to using a SqlDataSource. I am passing the ListView through the addList method and I have already created a new ListView in the new aspx file.
Please let me know the best way to handle this and if I need to add more information.
Code in First Class
public void CloneButton_Click(object sender, EventArgs e)
{
String droplist = DropDownList2.SelectedValue;
list = new ListView();
if (String.IsNullOrEmpty(droplist))
{
ScriptManager.RegisterStartupScript(this, GetType(), "error", "alert('Please select a Program Name and Report Period');", true);
return;
}
else
{
if (ListView1.Items.Count == 0)
{
Button1_Click(sender, e);
}
else
{
var selectAllCheckBox = (CheckBox)ListView1.InsertItem.FindControl("CheckBox2");
if (selectAllCheckBox.Checked == true)
{
list = ListView1;
Response.Redirect("~/CloneReport.aspx");
return;
}
for (int i = 0; i < ListView1.Items.Count; i++)
{
CheckBox chk = (CheckBox)ListView1.Items[i].FindControl("CheckBox1");
if (chk.Checked == true)
{
list.Items.Add(ListView1.Items[i]);
}
}
CloneReport rep = new CloneReport();
rep.addList(list);
Response.Redirect("~/CloneReport.aspx");
}
}
}
Code in Second Class
public void addList(ListView list)
{
ListView1 = new ListView();
for (int i = 0; i < list.Items.Count; i++)
{
ListView1.Items.Add(list.Items[i]);
}
ListView1.DataBind();
}
ListView Item Template From Old Page(Page Im transferring from)
<ItemTemplate>
<tr style="background-color: #E0FFFF; color: #333333;">
<td>
<asp:CheckBox ID="CheckBox1" runat="server" />
</td>
<td>
<asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Edit" />
<asp:Button ID="DeleteButton" runat="server" CommandName="Delete" Text="Delete" />
</td>
<td>
<asp:Label ID="FormTitleLabel" runat="server" Text='<%# Eval("FormTitle") %>' />
</td>
<td>
<asp:Label ID="FormSectionLabel" runat="server" Text='<%# Eval("FormSection") %>' />
</td>
<td>
<asp:Label ID="SubSectionLabel" runat="server" Text='<%# Eval("SubSection") %>' />
</td>
<td>
<asp:Label ID="SectionItemLabel" runat="server" Text='<%# Eval("SectionItem") %>' />
</td>
<td>
<asp:Label ID="SortOrder" runat="server" Text='<%# Eval("SortOrder") %>' />
</td>
<td>
<asp:Label ID="SectionSortOrder" runat="server" Text='<%# Eval("SectionSortOrder") %>' />
</td>
<td>
<asp:Label ID="SubSectionSortOrder" runat="server" Text='<%# Eval("SubSectionSortOrder") %>' />
</td>
<td>
<asp:Label ID="RuleDesc" runat="server" Text='<%# Eval("RuleDesc") %>' />
</td>
<td>
<asp:Label ID="ControlType" runat="server" Text='<%# Eval("ControlType") %>' />
</td>
<td>
<asp:Label ID="CrossItem" runat="server" Text='<%# Eval("CrossItem") %>' />
</td>
</tr>
</ItemTemplate>
Triggers for Update Panel
<Triggers>
<asp:AsyncPostBackTrigger ControlID="DropDownList1" />
<asp:AsyncPostBackTrigger ControlID="Button1" />
<asp:AsyncPostBackTrigger ControlID="CloneButton" />
</Triggers>
<ContentTemplate>
<div style="text-align: center;">
<asp:Button ID="CloneButton" runat="server" Text="Clone Report Period" OnClick="CloneButton_Click" />
</div>
<div style="text-align: center; position: absolute; margin-left: auto; margin-right: auto; left: 0; right: 0">
<b>Program Name</b>
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" DataSourceID="SqlDataSource2" DataTextField="Program" DataValueField="ProgramID">
</asp:DropDownList>
&nbsp &nbsp
<b>Report Period</b>
<asp:DropDownList ID="DropDownList2" runat="server" DataSourceID="SqlDataSource3" DataTextField="ReportLabel" DataValueField="DataCollectionPeriodID" Height="21px" Width="172px">
</asp:DropDownList>
<asp:Button ID="Button1" runat="server" Height="30px" OnClick="Button1_Click" Text="Search" />
</div>
You cannot transfer ListView object between pages, but you can do it with DataTable using Server.Transfer.
First Page:
DataTable dtTable;
public DataTable DataTransferTable
{
get { return dtTable; }
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
lstTransferView = new ListView();
DataView dtView = (DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty);
dtTable = new DataTable();
dtTable = dtView.ToTable().Clone();
DataRow dtRow;
foreach (ListViewDataItem lstItem in lstView.Items)
{
if (((CheckBox)lstItem.FindControl("chkBox")).Checked)
{
dtRow = (DataRow)dtView.Table.Rows[lstItem.DataItemIndex];
dtTable.ImportRow(dtRow);
}
}
Server.Transfer("~/SecondPage.aspx");
}
Second Page:
public FirstPageClass ftPage;
DataTable dtNewTable;
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
ftPage= (FirstPageClass)Context.Handler;
dtNewTable = (DataTable)ftPage.DataTransferTable;
lstSecondView.DataSource = dtNewTable;
lstSecondView.DataBind();
}

Passing values from Grid-View inside Modal popup Extender to the text box of parent form

I have a form with some text boxes and a button, which when clicked (button), a modalpopup extender will open with values display in grid-view (values from database),
If the user select any row, the name of the selected person must display in the text box of the parent form as shown below;
I have written this code,
C# Code:
//GridView inside the Modal popup
protected void grdPersonDetails_SelectedIndexChanged(object sender, EventArgs e)
{
GridViewRow row = grdPersonDetails.SelectedRow;
Session["testSession"] = row.Cells[0].Text;
ViewState["testViewState"] = row.Cells[0].Text;
ChargeFilterModalDialogExtender.Hide();
txtPersonName.Text = (string) ViewState["sometest"];
txtPersonName.Text = (string) Session["sometest"];
}
ASP Code:
<asp:Label ID="Label1" runat="Server" Text="Person Name:"></asp:Label>
<asp:TextBox runat="Server" ID="txtPersonName" />
<asp:Button runat="server" ID="btnSelectPerson" Text="Select Person" />
<ajax:ModalPopupExtender ID="ChargeFilterModalDialogExtender" runat="server" TargetControlID="btnSelectPerson" CancelControlID="BtnCloseChargeFilterControl" Drag="false" PopupControlID="Dialog_ChargeFilter" Enabled="True" BackgroundCssClass="modalBackground" />
<asp:Button ID="BtnShowDialog" Style="display: none" runat="server" Width="120" Text="Filter Charges" ToolTip="show Chargefilter-Dialog" />
<asp:Panel ID="Dialog_ChargeFilter" CssClass="modalPopup" runat="server">
<asp:Panel ID="DialogHeaderFrame" CssClass="DialogHeaderFrame" runat="server">
<asp:Panel ID="DialogHeader" runat="server" CssClass="DialogHeader" ScrollBars="Auto">
<asp:Label ID="LblPopupHeader" runat="server" Text="Charge-Filter" />
</asp:Panel>
</asp:Panel>
<asp:UpdatePanel ID="UpdGrdCharge" runat="server" UpdateMode="conditional" ChildrenAsTriggers="false">
<ContentTemplate>
<asp:Button ClientIDMode="Static" ID="BtnCloseChargeFilterControl" Text="close filter" ToolTip="close filter-dialog" CausesValidation="false" Width="150px" runat="server" OnClick="BtnCloseChargeFilterControl_Click" /><br />
<table border="1">
<tr>
<td dir="rtl">
<asp:GridView ID="grdPersonDetails" runat="server" AutoGenerateColumns="False" DataKeyNames="PersonName,PersonEmail" DataSourceID="TempSqlDataSource" OnSelectedIndexChanged="grdPersonDetails_SelectedIndexChanged">
<Columns>
<asp:BoundField DataField="PersonName" HeaderText="Person Name" ReadOnly="True" SortExpression="PersonName" />
<asp:BoundField DataField="PersonEmail" HeaderText="Person Email" ReadOnly="True" SortExpression="PersonEmail" />
<asp:TemplateField HeaderText="Select">
<ItemTemplate>
<asp:Button ID="Button1" runat="server" CommandName="Select" Text="Button" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</td>
</tr>
</table>
<asp:SqlDataSource ID="TempSqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>" SelectCommand="select * from person.persons"></asp:SqlDataSource>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Panel>
The issue is that when I am selecting a person in the grid-view (inside the modal popup), the selected person name not appear in the related text box in the parent form. (when debugging it, it shows that the value of person name set in the text box)
Hi Abdul here is a complete demo - tested by me - working 100% successfully.
<%# Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
CodeBehind="Default.aspx.cs" Inherits="ModalPopupExtenderAJAXToolkitWebApp._Default" %>
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
<style type="text/css">
.searchButton
{
left: 319px;
position: absolute;
top: 145px;
width: 27px;
}
</style>
<link href="Styles/jquery.tooltip.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.3.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
//Hiding Table Available inside div #dvDetails
// $('#dvDetails').hide();
/* Binding click event to each imagebutton inside GridView1
* which is taking value from current row and assigning
* to controls inside table
*/
$("#<%=GridView1.ClientID %> input[name*='imgbtn']").each(function (index) {
$("#<%=GridView1.ClientID %> input[name*='imgbtn']").bind('click', function (e) {
var id = $(this).closest('tr').find("span[id*='lblUserId']").text();
var username = $(this).closest('tr').find("input[name*='txtUserName']").val();
var firstname = $(this).closest('tr').find("input[name*='txtFirstName']").val();
var lastname = $(this).closest('tr').find("input[name*='txtLastName']").val();
var city = $(this).closest('tr').find("input[name*='txtCity']").val();
var designation = $(this).closest('tr').find("input[name*='txtDesignation']").val();
$('#<%=lblID.ClientID %>').text(id);
$('#<%=lblusername.ClientID %>').text(username);
$('#<%=txtfname.ClientID %>').val(firstname);
$('#<%=txtlname.ClientID %>').val(lastname);
$('#<%=txtCity.ClientID %>').val(city);
$('#<%=txtDesg.ClientID %>').val(designation);
});
});
/* Binding click event to each selected radiobutton inside GridView1
* which is taking value from current row and assigning
* to controls inside table
*/
$('input[value=Remove]').click(function () {
$('#dvDetails').show();
var id = $(this).closest('tr').find("span[id*='lblUserId']").text();
var username = $(this).closest('tr').find("input[name*='txtUserName']").val();
var firstname = $(this).closest('tr').find("input[name*='txtFirstName']").val();
var lastname = $(this).closest('tr').find("input[name*='txtLastName']").val();
var city = $(this).closest('tr').find("input[name*='txtCity']").val();
var designation = $(this).closest('tr').find("input[name*='txtDesignation']").val();
$('#<%=lblID.ClientID %>').text(id);
$('#<%=lblusername.ClientID %>').text(username);
$('#<%=txtfname.ClientID %>').val(firstname);
$('#<%=txtlname.ClientID %>').val(lastname);
$('#<%=txtCity.ClientID %>').val(city);
$('#<%=txtDesg.ClientID %>').val(designation);
});
var $fieldRevItems = $("#dvDetails");
$('#<%=btnClose2.ClientID %>').click(function (e) {
$('#<%=txtSearch.ClientID %>').val('');
// $fieldRevItems.hide('slow');
$fieldRevItems.slideUp(600);
e.preventDefault();
});
});
</script>
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<h2>
Welcome to ASP.NET!
</h2>
<asp:ToolkitScriptManager ID="ScriptManager1" runat="server">
</asp:ToolkitScriptManager>
<div id="dvMain" style="height: 341px; width: 928px">
<div id="dvFirst">
Search user Details : <asp:TextBox ID="txtSearch" runat="server"></asp:TextBox>
<asp:ImageButton ID="imgSearch" CssClass="searchButton" title="Search data for this id"
ImageUrl="~/search2.jpg" runat="server" OnClick="imgSearch_Click" />
<asp:Button ID="btnShowPopup2" runat="server" Style="display: none" />
<br />
<br />
<asp:ModalPopupExtender ID="ModalPopupExtender2" runat="server" TargetControlID="btnShowPopup2"
PopupControlID="pnlpopup2" CancelControlID="btnClose" BackgroundCssClass="modalBackground">
</asp:ModalPopupExtender>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Panel ID="pnlpopup2" runat="server" BackColor="Green" Height="269px" Width="600px"
Style="display: none; top: 191px;width: 780px;">
<asp:GridView runat="server" ID="GridView1" 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="UserId">
<ItemTemplate>
<asp:Label ID="lblUserId" style="width:100px;" runat="server" Text='<%# Eval("UserId") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:Label ID="lblUserId" style="width:100px;" runat="server" Text='<%# Eval("UserId") %>'></asp:Label>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="UserName">
<ItemTemplate>
<asp:TextBox ID="txtUserName" style="width:100px;" CssClass="css2" runat="server"
Text='<%# Eval("UserName")%>'></asp:TextBox>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtUserName" CssClass="css2" runat="server"
Text='<%# Eval("UserName")%>'></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="FirstName">
<ItemTemplate>
<asp:TextBox ID="txtFirstName" style="width:100px;" CssClass="css2" runat="server"
Text='<%# Eval("FirstName")%>'></asp:TextBox>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtFirstName" style="width:100px;" CssClass="css2" runat="server"
Text='<%# Eval("FirstName")%>'></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="LastName">
<ItemTemplate>
<asp:TextBox ID="txtLastName" style="width:100px;" CssClass="css2" runat="server"
Text='<%# Eval("LastName")%>'></asp:TextBox>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtLastName" style="width:100px;" CssClass="css2" runat="server"
Text='<%# Eval("LastName")%>'></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="City">
<ItemTemplate>
<asp:TextBox ID="txtCity" style="width:100px;" CssClass="css2" runat="server"
Text='<%# Eval("City")%>'></asp:TextBox>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtCity" style="width:100px;" CssClass="css2" runat="server"
Text='<%# Eval("City")%>'></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Designation">
<ItemTemplate>
<asp:TextBox ID="txtDesignation" style="width:100px;" CssClass="css2" runat="server"
Text='<%# Eval("Designation")%>'></asp:TextBox>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtDesignation" style="width:100px;" CssClass="css2" runat="server"
Text='<%# Eval("Designation")%>'></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Close">
<ItemTemplate>
<asp:Button ID="btnCancel" runat="server" Text="Cancel" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Select">
<ItemTemplate>
<asp:RadioButton ID="rbSelectUserId" runat="server" Checked="false" value="Remove"
AutoPostBack="true" CausesValidation="false"
/>
<asp:ImageButton ID="imgbtn" ImageUrl="~/Edit.jpg" runat="server" Width="25" Height="25"/>
</ItemTemplate>
</asp:TemplateField>
</columns>
</asp:GridView>
<asp:Button ID="btnClose" runat="server" Text="Cancel" />
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
<br />
<br />
</div>
<div id="dvDetails">
<table id="tblDetails" width="30%" style="border: Solid 3px #D55500; 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">
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" style="width: 100%">
Designation:
</td>
<td>
<asp:TextBox ID="txtDesg" runat="server" />
</td>
</tr>
<tr>
<td align="center" style="width: 100%">
<asp:Button ID="btnClose2" runat="server" Text="Close" />
</td>
</tr>
</table>
</div>
</div>
</asp:Content>
//====================================================================================
and here is your code behind file.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
using System.Drawing;
using System.Configuration;
namespace ModalPopupExtenderAJAXToolkitWebApp
{
public partial class _Default : System.Web.UI.Page
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["conString"].ToString());
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindGridData();
}
}
protected void BindGridData()
{
con.Open();
using (SqlCommand cmd = new SqlCommand("Select * from Employee_Details", con))
{
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
GridView1.DataSource = dt;
GridView1.DataBind();
UpdatePanel1.Update();
}
}
protected DataTable SearchDetails(string id)
{
DataTable dt = new DataTable();
con.Open();
using (SqlCommand cmd = new SqlCommand("Select * from Employee_Details where UserId=#UserId", con))
{
cmd.Parameters.Add(new SqlParameter("#UserId",Convert.ToInt32(id)));
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(dt);
}
return dt;
}
protected void imgSearch_Click(object sender, EventArgs e)
{
string id = txtSearch.Text;
if (id != null)
{
DataTable dt = new DataTable();
dt = SearchDetails(id);
GridView1.DataSource = dt;
GridView1.DataBind();
UpdatePanel1.Update();
this.ModalPopupExtender2.Show();
}
}
}
}

Categories