Auto add row in table HTML - c#

I have an table in my page that lists User and Email when user sends this information
How I can make this table add an row for each post and not delete other line?
My aspx
<table id="tblUsers" class="table table-bordered table-striped">
<tbody id="tbodyUser">
<tr>
<asp:Label ID="lblHeader" Font-Bold="true" runat="server" Visible="false">User to Access</asp:Label>
<td>
<asp:Label ID="lblUser" runat="server" Visible="false"></asp:Label>
</td>
<td>
<asp:Label ID="lblEmail" runat="server" Visible="false"></asp:Label>
</td>
</tr>
</tbody>
</table>
My .cs
protected void btnSendUser_OnClick(object sender, EventArgs e)
{
string LoginInfo = txtUserAdd.Text;
PrincipalContext insPrincipalContext = new PrincipalContext(ContextType.Domain, "x.com", "amsndrsecuritysqlser", "xxx");
UserPrincipal insUserPrincipal = UserPrincipal.FindByIdentity(insPrincipalContext, LoginInfo);
//it's to first post
if (lblUser.Visible == false && lblEmail.Visible == false)
{
if (insUserPrincipal == null)
{
lblError.Visible = true;
}
else
{
lblUser.Visible = true;
lblEmail.Visible = true;
lblHeader.Visible = true;
lblUser.Text = insUserPrincipal.GivenName + " " + insUserPrincipal.Surname;
lblEmail.Text = insUserPrincipal.EmailAddress;
}
}
}

You must add runat="server" to your table tblUsers
var row =new System.Web.UI.HtmlControls.HtmlTableRow();
var cell = new System.Web.UI.HtmlControls.HtmlTableCell();
cell.InnerText = "New Cell";
row.Cells.Add(cell);
tblUsers.Rows.Add(row);

It would be one of some possible solutions:
Store your data in a collection
In every button click, update the data and put it in session
Bind the session data to a Repeater in your page (the binding code MUST be in Page_Load)
The Repeater markup would be something like this
<asp:Repeater ID="Repeater1" runat="server">
<HeaderTemplate>
<table id="tblUsers" class="table table-bordered table-striped">
<tbody id="tbodyUser">
</HeaderTemplate>
<ItemTemplate>
<tr>
<asp:Label ID="lblHeader" Font-Bold="true" runat="server" Visible="<% #lblHeaderVisibilty %>">User to Access</asp:Label>
<td>
<asp:Label ID="lblUser" runat="server" Visible="<% #lblUserVisibilty %>"></asp:Label>
</td>
<td>
<asp:Label ID="lblEmail" runat="server" Visible="<% #lblEmailVisibilty %>"></asp:Label>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</tbody>
</table>
</FooterTemplate>
</asp:Repeater>

Related

Highlight ListView row without re-bind or apply style to that row

Typical listview.
<asp:ListView ID="ListView1" runat="server" DataKeyNames="ID" OnSelectedIndexChanging="ListView1_SelectedIndexChanging"
OnSelectedIndexChanged="ListView1_SelectedIndexChanged">
<ItemTemplate>
<tr style="">
<td>
<asp:Label ID="FirstNameLabel" runat="server" Text='<%# Eval("FirstName") %>' />
</td>
<td>
<asp:Label ID="LastNameLabel" runat="server" Text='<%# Eval("LastName") %>' />
</td>
<td>
<asp:Label ID="HotelNameLabel" runat="server" Text='<%# Eval("HotelName") %>' />
</td>
<td>
<asp:Label ID="CityLabel" runat="server" Text='<%# Eval("City") %>' />
</td>
<td>
<asp:Button ID="cmdLstSel" runat="server" Text="View" CssClass="btn"
CommandName="Select"/>
</td>
</tr>
</ItemTemplate>
<SelectedItemTemplate>
<tr style="" class="alert-info">
<td>
<asp:Label ID="FirstNameLabel" runat="server" Text='<%# Eval("FirstName") %>' />
</td>
<td>
<asp:Label ID="LastNameLabel" runat="server" Text='<%# Eval("LastName") %>' />
</td>
<td>
<asp:Label ID="HotelNameLabel" runat="server" Text='<%# Eval("HotelName") %>' />
</td>
<td>
<asp:Label ID="CityLabel" runat="server" Text='<%# Eval("City") %>' />
</td>
<td>
<asp:Button ID="cmdLstSel" runat="server" Text="View" CssClass="btn" OnClick="cmdLstSel_Click" />
</td>
</tr>
</SelectedItemTemplate>
<LayoutTemplate>
<table runat="server">
<tr runat="server">
<td runat="server">
<table id="itemPlaceholderContainer" runat="server" border="0" style="">
<tr runat="server" style="">
<th runat="server">FirstName</th>
<th runat="server">LastName</th>
<th runat="server">HotelName</th>
<th runat="server">City</th>
<th runat="server">View</th>
</tr>
<tr id="itemPlaceholder" runat="server">
</tr>
</table>
</td>
</tr>
<tr runat="server">
<td runat="server" style="">
<asp:DataPager ID="DataPager1" runat="server">
<Fields>
<asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True" ShowLastPageButton="True" />
</Fields>
</asp:DataPager>
</td>
</tr>
</table>
</LayoutTemplate>
</asp:ListView>
So we can highlight the row clicked with:
protected void ListView1_SelectedIndexChanging(object sender, ListViewSelectEventArgs e)
{
}
protected void ListView1_SelectedIndexChanged(object sender, EventArgs e)
{
GPayments.DataSource = MyRst("SELECT * FROM HotelPayments WHERE Hotel_ID = " + hID);
GPayments.DataBind();
}
Now if I leave out the re-bind, then of course the row will highlight, but of course it is the "previous" row that hight lights.
And if I could set the class of the ONE row, then I could dump the selected item template.
You can do this with GREAT ease in a GridView, and I often do this:
Dim gRow As GridViewRow = -- get any row
gRow.CssClass = " alert-info"
however, I would like to do the same with listView. When I do above for GridView, then I don't need or have to bother with a re-bind, and I don't even need a selected template either.
So left is a grid view, and we get this:
However, I want to do this with listview.
(and WITHOUT having to do a re-bind).
Any simple way to highlight a row in ListView WITHOUT a re-bind?
Ok, a bit of googling, and the solution becomes VERY easy.
The goal here is to click on a row - highlight that row.
Of course WAY too much work to have to include a selected row template.
It is a better trade off to add 3 lines of code to do this.
So, say we have this markup:
<asp:ListView ID="ListView1" runat="server" DataKeyNames="ID"
OnSelectedIndexChanged="ListView1_SelectedIndexChanged" OnSelectedIndexChanging="ListView1_SelectedIndexChanging" >
<ItemTemplate>
<tr id="mytr" runat="server">
<td><asp:Label ID="FirstNameLabel" runat="server" Text='<%# Eval("FirstName") %>' /></td>
<td><asp:Label ID="LastNameLabel" runat="server" Text='<%# Eval("LastName") %>' /></td>
<td><asp:Label ID="HotelNameLabel" runat="server" Text='<%# Eval("HotelName") %>' /></td>
<td><asp:Label ID="CityLabel" runat="server" Text='<%# Eval("City") %>' /></td>
<td>
<asp:Button ID="cmdLstSel" runat="server" Text="View" CssClass="btn"
CommandName="Select" OnClick="cmdLstSel_Click"/>
</td>
</tr>
</ItemTemplate>
<LayoutTemplate>
<table id="itemPlaceholderContainer" runat="server" border="0" class="table table-hover" style="">
<tr runat="server" style="">
<th runat="server">FirstName</th>
<th runat="server">LastName</th>
<th runat="server">HotelName</th>
<th runat="server">City</th>
<th runat="server">View</th>
</tr>
<tr id="itemPlaceholder" runat="server">
</tr>
</table>
</LayoutTemplate>
</asp:ListView>
ok, our code to fill is this:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
LoadView();
}
}
void LoadView()
{
ListView1.DataSource = MyRst("SELECT TOP 12 * FROM tblHotels ORDER BY HotelName");
ListView1.DataBind();
}
Output:
Ok, so for the row click? Well, we don't have to use the selected index changed, but, for this we will (so CommandName="Select" is what triggers that index changed event).
However, I want a simple button click, and with some code (to display the details part).
So, our button click is this:
protected void cmdLstSel_Click(object sender, EventArgs e)
{
Button btn = (Button)sender;
ListViewDataItem gRow = (ListViewDataItem)btn.Parent.Parent.Parent;
int hID = (int)ListView1.DataKeys[gRow.DisplayIndex]["ID"];
GHotelOptions.DataSource = MyRst("SELECT * FROM HotelOptions WHERE Hotel_ID = " + hID);
GHotelOptions.DataBind();
GPayments.DataSource = MyRst("SELECT * FROM HotelPayments WHERE Hotel_ID = " + hID);
GPayments.DataBind();
}
Above will fill the child tables. Note the cool trick to get the row - I don't bother with the listview event model!
Now for the row highlight.
The trick is to add an "id" to the tr row like this:
<ItemTemplate>
<tr id="mytr" runat="server">
So, we can now pick up the tr element.
So on lv index changed, we do this:
protected void ListView1_SelectedIndexChanged(object sender, EventArgs e)
{
ListViewItem gRow = (ListViewItem)ListView1.Items[ListView1.SelectedIndex];
if ( (ViewState["MySel"] != null) && ((int)ViewState["MySel"] != gRow.DataItemIndex) )
{
ListViewItem gLast = ListView1.Items[(int)ViewState["MySel"]];
HtmlTableRow hTRL = (HtmlTableRow)gLast.FindControl("mytr");
hTRL.Attributes.Add("class", "");
}
HtmlTableRow hTR = (HtmlTableRow)gRow.FindControl("mytr");
hTR.Attributes.Add("class", "alert-info");
ViewState["MySel"] = gRow.DataItemIndex;
}
So, I did use row state, but that lets me un-highlight + highlight, and I do NOT hve to re-bind the grid.
And I just picked a nice boot strap class - it even "reverses" the text - very nice.
So now we get this:
So this did cost about 4-5 extra lines. But, we trade that for NOT having a selected template in the lv (and that's too much to maintain both the row layout and THEN have to maintains the same for selected template. And worse, you STILL had to re-bind for the highlighted row click to show. This way, we don't.
I also used a "helper" routine to get a datatable, and that was this:
public DataTable MyRst(string strSQL)
{
DataTable rstData = new DataTable();
using (SqlCommand cmdSQL = new SqlCommand(strSQL,
new SqlConnection(Properties.Settings.Default.TEST3)))
{
cmdSQL.Connection.Open();
rstData.Load(cmdSQL.ExecuteReader());
}
return rstData;
}
At the end of the day, we can now highlight the row, do so with a click, and we could even move the selected index changed code to our button code and not even use the lv index and built in events.

hide column in an asp.net listview?

I have below list view , how can i hide column by code behind ?
<asp:ListView ID="AuditLogListView" runat="server" OnItemCreated="AuditLogListView_ItemCreated">
<LayoutTemplate>
<table class="table table-striped table-bordered small">
<tr class="table-secondary">
<th id="BlockHeader" runat="server" style="white-space: normal;">
<asp:Literal ID="BlockHeaderLiteral" runat="server" Text="<%$ Resources:AppResources, AuditInformationBlockHeader %>" />
</th>
</tr>
<asp:PlaceHolder runat="server" ID="ItemPlaceholder"></asp:PlaceHolder>
</table>
</LayoutTemplate>
<ItemTemplate>
<tr>
<td id="BlockStatus" runat="server">
<%# Eval("BlockStatus")%>
</td>
</tr>
</ItemTemplate>
After binding data with list view i tried below code behind but with this header text only hide but column still can still visible
if (groupOrBlockValue == 'W')
{
AuditLogListView.FindControl("BlockHeader").Visible = false;
AuditLogListView.FindControl("BlockHeaderLiteral").Visible = false;
//AuditLogListView.FindControl("BlockStatus").Visible = false;
}
Missing part of the list view?
With this:
<asp:ListView ID="LstMarks" runat="server" DataKeyNames="ID" >
<ItemTemplate>
<tr style="">
<td><asp:Textbox ID="Course" runat="server" Text='<%# Eval("Course") %>' /></td>
<td><asp:Textbox ID="Mark" runat="server" Text='<%# Eval("Mark") %>' Width="30px"/></td>
<td>
<asp:CheckBox ID="DoneLabs" runat="server" Checked = '<%# Eval("DoneLabs") %>' Width="30px"/>
</td>
</tr>
</ItemTemplate>
<LayoutTemplate>
<table id="itemPlaceholderContainer" runat="server" border="0" class="table">
<tr runat="server" style="">
<th runat="server" >Course</th>
<th runat="server">Mark</th>
<th id= "LabW" runat="server" >Completed Lab Work</th>
</tr>
<tr id="itemPlaceholder" runat="server">
</tr>
</table>
</LayoutTemplate>
</asp:ListView>
<br />
<br />
<asp:Button ID="cmdHide" runat="server" Text="Hide Lab check box" OnClick="cmdHide_Click" />
So note in the layout, we added a "id" = LabW - that lets you hide the header.
so, a simple button that would toggle (hide/show) the lvColum, then this works:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
using (SqlCommand cmdSQL = new SqlCommand("SELECT * from StudentCourses",
new SqlConnection(Properties.Settings.Default.TEST4)))
{
cmdSQL.Connection.Open();
LstMarks.DataSource = cmdSQL.ExecuteReader();
LstMarks.DataBind();
}
}
}
protected void cmdHide_Click(object sender, EventArgs e)
{
Control ctrHeader = LstMarks.FindControl("LabW");
ctrHeader.Visible = !ctrHeader.Visible;
foreach (ListViewItem lvRow in LstMarks.Items)
{
CheckBox ckBox = (CheckBox)lvRow.FindControl("DoneLabs");
ckBox.Visible = !ckBox.Visible;
}
}
So, we get this:
And clicking on the button, we get this:
And both the values changed - they persist - even when you click again (to toggle and show the hidden columns).
Edit: =====================================================
So, say this markup:
<asp:ListView ID="AuditLogListView" runat="server"
OnItemCreated="AuditLogListView_ItemCreated">
<LayoutTemplate>
<table class="table table-striped table-bordered small">
<tr class="table-secondary">
<th id="BlockHeader" runat="server" style="white-space: normal;">
<asp:Literal ID="BlockHeaderLiteral" runat="server" Text="Hotel Name" />
</th>
</tr>
<asp:PlaceHolder runat="server" ID="ItemPlaceholder"></asp:PlaceHolder>
</table>
</LayoutTemplate>
<ItemTemplate>
<tr>
<td id="BlockStatus" runat="server">
<%# Eval("BlockStatus")%>
</td>
</tr>
</ItemTemplate>
</asp:ListView>
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
And code behind button to hide is this:
protected void Button1_Click(object sender, EventArgs e)
{
Control ctrHeader = AuditLogListView.FindControl("BlockHeaderLiteral");
ctrHeader.Visible = !ctrHeader.Visible;
foreach (ListViewItem lvRow in AuditLogListView.Items)
{
Control BlockStat = (Control)lvRow.FindControl("BlockStatus");
BlockStat.Visible = !BlockStat.Visible;
}
}
At which event have you written this code?
Required this code in the OnDataBound event. And in your code this event missing.
<asp:ListView ID="AuditLogListView" runat="server" OnItemCreated="AuditLogListView_ItemCreated" OnDataBound="AuditLogListView_DataBound">
<asp:Literal ID="BlockHeaderLiteral" runat="server" Text="<%$ Resources:AppResources, AuditInformationBlockHeader %>" /><asp:PlaceHolder runat="server" ID="ItemPlaceholder"></asp:PlaceHolder>
C# Code:
protected void AuditLogListView_DataBound(object sender, EventArgs e)
{AuditLogListView.FindControl("BlockHeaderLiteral").Visible = false;}

How get data from database column as a heading using Repeater in ASP.NET

image
The Upper portion of present my database table structure and lower portion that in which form i want to show data.
<table class="table table-bordered table-hover">
<thead>
<tr class="text-center">
<th>Course Code</th>
<th>Subject</th>
<th>Cr.Hours</th>
<th>Grade</th>
</tr>
<tr>
<td colspan="4">
<asp:Label ID="Label5" runat="server" Text="Label"></asp:Label>
</td>
</tr>
</thead>
<tbody>
<asp:Repeater ID="outer" runat="server">
<ItemTemplate>
<tr>
<td>
<asp:Label Text='<%#Eval("[SpringFall]")%>' Style="text-align: center; display: none; font-size: 18px; font-family: 'Times New Roman'" ID="Label4" runat="server" Font-Bold="true"> </asp:Label>
</td>
<td>
<asp:Label ID="AllCcode" runat="server" Text='<%#Eval("[Course_Code]") %>'></asp:Label>
</td>
<td>
<asp:Label ID="AllSubject" runat="server" Text='<%#Eval("[Subject]") %>'></asp:Label>
</td>
<td>
<asp:Label ID="AllCrHr" runat="server" Text='<%#Eval("[Credit_Hours]") %>'></asp:Label>
</td>
<td>
<asp:Label ID="AllGrade" Font-Bold="true" runat="server" Text='<%#Eval("[Total_Marks]") %>'></asp:Label>
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
</tbody>
</table>
Here Is my code..bind repeater on button click event using c# with simple sql SELECT query.Any query for bind repeater with more efficient working and show data in given form.
protected void AttendencBtn_Click(object sender, EventArgs e)
{
// MultiView1.ActiveViewIndex = 8;
conn.Open();
sda = new SqlDataAdapter("SELECT * FROM Attendence where Roll_Number='" + Session["RollNumb"] + "' ", conn);
dt = new DataTable();
sda.Fill(dt);
AttendencRpt.DataSource = dt;
AttendencRpt.DataBind();
conn.Close();
}
I think you are looking for something like this. First create a public variable in code behind.
public int currentYear = 2000;
protected void Page_Load(object sender, EventArgs e)
{
}
Then change the Repeater to something like this:
<table border="1">
<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
<%# Convert.ToDateTime(Eval("myYear")).Year != currentYear && Container.ItemIndex > 0 ? "<tr><td colspan=\"5\">" + Eval("myYear") + "</td></tr>" : "" %>
<tr>
<td>
normal rows here
</td>
</tr>
<%# currentYear = Convert.ToDateTime(Eval("myYear")).Year %>
</ItemTemplate>
</asp:Repeater>
</table>
What will happen is that the value of currentYear is compared to the current row value. If it does not match a new row will be created. Then the value of currentYear is updated to be checked in the next row bound to the Repeater.

asp:c# Print checked rows using checkbox

i want to print the selected rows in a repeater table when a button clicked, this is the .aspx code:
<asp:Repeater ID="rptItems" runat="server">
<HeaderTemplate>
<table class="table table-bordered table-hover table-responsive table-striped table-condensed">
<tr>
<th> </th>
<th>Goods Desc</th>
<th>Balance Units</th>
<th>Exit Units</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td><asp:CheckBox ID="cbItem" runat="server" ClientIDMode="AutoID" AutoPostBack="True" /></td>
<td><asp:Label runat="server" Id="lblCampCode" Text='<%#Eval("ItemDesc") %>'></asp:Label></td>
<td><asp:Label ID="lblBalUnits" runat="server" text='<%#Eval("InvoicBalanceUnits") %>'></asp:Label> </td>
<td><asp:TextBox ID="txtExitUnits" runat="server"></asp:TextBox>
<asp:RegularExpressionValidator ID="revUnits" runat="server" Display="Dynamic" ControlToValidate="txtExitUnits" ValidationExpression="^\d+$" ErrorMessage="Please, insert a number." CssClass="text-danger"></asp:RegularExpressionValidator>
<asp:RequiredFieldValidator ID="rfvUnits" runat="server" Display="Dynamic" ControlToValidate="txtExitUnits" ErrorMessage="Insert number of units." CssClass="text-danger"></asp:RequiredFieldValidator>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
<asp:Button ID="btnExit" runat="server" Text="Exit now" OnClick="btnExit_Click" />
and this is the .cs code for button click event which will loop for ever checked item in the repeater, and will retrieve the checked rows data:
protected void btnExit_Click(object sender, EventArgs e)
{
foreach (RepeaterItem item in rptItems.Items)
{
if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem)
{
CheckBox checkBoxInRepeater = item.FindControl("cbItem") as CheckBox;
if (checkBoxInRepeater.Checked)
{
Label lblCampCode = (Label)item.FindControl("lblCampCode");
Label lblBalUnits = (Label)item.FindControl("lblBalUnits");
TextBox txtExitUnits = (TextBox)item.FindControl("txtExitUnits");
string CampCode = lblCampCode.Text;
string BalUnits = lblBalUnits.Text;
string ExitUni = txtExitUnits.Text;
}
}
}
}
i think that i should use datatable to store the data.
I solve it by using Datatable like this:
DataTable checkedData = new DataTable();
checkedData.Columns.AddRange(new DataColumn[6] { new DataColumn("CampCode"), new DataColumn("BalUnits", typeof(decimal)), new DataColumn("ExitUni",typeof(decimal)), new DataColumn("itemNum"), new DataColumn("UOM"), new DataColumn("WT", typeof(decimal)) });
dr["CampCode"]=lblexitUnits.text;
//And so on
DataRow dr = checkedData.NewRow();

How to get the selected DDL value from a row in ListView

right now I am just trying to put together a simple role assigning pages in ASP.NET, I have created a listview, and in my item template I have a drop down list, with a button in the same template. The DDL is hooked up to an ODS which gets me the current roles, and I have a method which will take the role and the username, and assign that user to a specific role. My code is as follows:
<h2>Users</h2>
<asp:ListView ID="UserListView" runat="server"
ItemType="Synergy_System.Entities.Security.ApplicationUser"
OnItemCommand="UserListView_ItemCommand">
<EmptyDataTemplate>
<table runat="server">
<tr>
<td>
No users in this site.
<asp:LinkButton runat="server" CommandName="AddUsers" Text="Add users" ID="AddUsersButton" />
</td>
</tr>
</table>
</EmptyDataTemplate>
<ItemTemplate>
<tr>
<td>
<asp:Label Text='<%# Item.UserName %>' runat="server" ID="UserNameLabel" /></td>
<td>
<asp:Label Text='<%# Item.Email %>' runat="server" ID="EmailLabel" /></td>
<td><em>password is hashed</em></td>
<td>
<asp:DropDownList ID="RolesList" runat="server" DataSourceID="RoleListODS" DataTextField="Name" DataValueField="Name">
</asp:DropDownList>
<asp:Button ID="AddRoleToUser" runat="server" Text="Add Role" onclick="AddRoleToUser_Click" />
</td>
</tr>
</ItemTemplate>
<LayoutTemplate>
<table runat="server">
<tr runat="server">
<td runat="server">
<table runat="server" id="itemPlaceholderContainer"
class="table table-condensed table-hover table-striped">
<tr runat="server">
<th runat="server">User Name</th>
<th runat="server">Email</th>
<th runat="server">Password</th>
<th runat="server">Roles</th>
</tr>
<tr runat="server" id="itemPlaceholder"></tr>
</table>
</td>
</tr>
<tr runat="server">
<td runat="server">
<asp:DataPager runat="server" ID="DataPager1">
<Fields>
<asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True" ShowLastPageButton="True"></asp:NextPreviousPagerField>
</Fields>
</asp:DataPager>
</td>
</tr>
</table>
</LayoutTemplate>
I have code behind pretty much empty, as it's just like this right now:
protected void AddRoleToUser_Click(object sender, EventArgs e)
{
string username;
string role;
//get username
//get value from DDL
UserManager.AddUserToRole(username,role);
}
I have used GridViews before but haven't dealt with ListViews much. I just want it so that when I click the button in that particular row, i retrieve this information, but there is no .Row in a listview.... any help would be greatly appreciated.
You can Use CommandName property of Button
<asp:Button ID="AddRoleToUser" CommandName="AddRole"
Code Behind
protected void UserListView_ItemCommand(object sender, ListViewCommandEventArgs e)
{
if (String.Equals(e.CommandName, "AddRole"))
{
ListViewDataItem dataItem = (ListViewDataItem)e.Item;
// this will gives you Row for your list items
Label UserNameLabel=(Label)dataItem.FindControl("UserNameLabel");
// you can find any control on row like this
string YourNameLabel=UserNameLabel.Text;
}
}

Categories