I make i my own mail interface system into my application and since the user click on Repsendbtn into listview called " viewmsgView " then he will hide the " viewmsgView" and show " repmsgform " and bind the data into repmsgform depending on mailno. What i am facing is as you all know that cant reach controls into listview or formview and the Repsendbtn is inside the formview and it will depend on others controls to process the below behind code but i am getting red-line under the controls id with message: " The name 'Label' does not exist in the current context " so how i can solve this case and make the button code work smoothly. Its may really not so clear my post, so i decide to make record screen which i hope will make it easily to explain what i am looking for. Please click on the below link and have a look of my screen record where i explain what i am looking for:
https://www.youtube.com/watch?v=OMKp7b6iMJ8&feature=youtu.be
<asp:FormView ID="repmsgform" runat="server" DataKeyNames="mailno" Width="100%" >
<ItemTemplate>
<div>
<table class="table table-bordered" style="margin-left:0px;" >
<tbody>
<tr>
<td style="border-collapse:collapse; border:2px solid white; color:#333333; background-color:#f0f0f0;">
Ads Number:
</td>
<td >
<asp:Label ID="adsnummsglbl" runat="server" Text='<%# Bind("AdsID") %>' ></asp:Label>
</td>
</tr>
<tr>
<td td style="border-collapse:collapse; border:2px solid white; color:#333333; background-color:#f0f0f0;">
Message Title:
</td>
<td>
<asp:Label ID="adstitmsglbl" runat="server" Color="#669900" Text='<%# Bind("Mestitle") %>'></asp:Label>
</td>
</tr>
<tr>
<td td style="border-collapse:collapse; border:2px solid white; color:#333333; background-color:#f0f0f0;">
From:
</td>
<td>
<asp:Label ID="Reciverlblnme" runat="server" Text='<%# Bind("Receiver") %>'></asp:Label>
</td>
</tr>
<tr>
<td style="border-collapse:collapse; border:2px solid white; color:#333333; background-color:#f0f0f0;">To:</td>
<td> <asp:Label ID="Tolbl" runat="server" Text='<%# Bind("sender") %>'></asp:Label></td>
</tr>
</tbody>
</table>
<div class="form-group">
<asp:Label ID="Label12" runat="server" Text="Label" CssClass="col-md-3 control-label">Your Message:</asp:Label>
<div class="col-md-9">
<asp:TextBox ID="TextBox1" runat="server" Height="150px" TextMode="multiline" CssClass="form-control"
></asp:TextBox>
</div>
</div>
<asp:Label ID="msgsentlbl" runat="server" Font-Size="Medium" ForeColor="#669900"></asp:Label>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<div class="pull-right">
<asp:Button ID="Closebtn" runat="server" Text="Close"
CssClass="btn btn-default" onclick="Closebtn_Click"/>
<asp:Button runat="server" ID="Repsendbtn" Text="Send" CssClass="btn btn-primary"
onclick="Repsendbtn_Click"/></div>
</div></div>
</ItemTemplate>
</asp:FormView>
protected void Repsendbtn_Click(object sender, EventArgs e)
{
if (Session["UsrNme"] != null)
{
using (SqlConnection cn = new SqlConnection(sc))
{
string SendMsgSQL = #"INSERT mails [CVs] ([Message], [Mestitle], [AdsID], [Date], [Receiver], [sender])
VALUES (#Message, #Mestitle, #AdsID , #Date, #Receiver, #sender)";
using (SqlCommand SendMsgcmd = new SqlCommand(SendMsgSQL, cn))
{
cn.Open();
var user = Session["UsrNme"];
SendMsgcmd.Parameters.AddWithValue("#sender", user);
SendMsgcmd.Parameters.AddWithValue("#Message", TextBox1.Text);
SendMsgcmd.Parameters.AddWithValue("#Mestitle", adstitmsglbl.Text);
SendMsgcmd.Parameters.AddWithValue("#AdsID", adsnummsglbl.Text);
SendMsgcmd.Parameters.AddWithValue("#Date", DateTime.Now);
SendMsgcmd.Parameters.AddWithValue("#Receiver", Reciverlblnme.Text);
SendMsgcmd.ExecuteNonQuery();
Response.Redirect("User panel.aspx");
}
}
}
else
{
// Consider throwing an error (if these fields are required)
}
}
Related
I need to access a label text to another in the repeater
<asp:Repeater runat="server" ID="Repeater1">
<ItemTemplate>
<tr role="row" class="odd">
<td><asp:Label ID="Label1" runat="server" Text='<%# Eval("strRoles") %>'></asp:Label><%--<%# Eval("strRoles")%>--%></td>
<td><%if ( Label1.Text == "Creator") {%>
<a href="#modal-danger" data-toggle="modal"
onclick='<%# Eval("intProjectId", "saveID(\"{0}\")")%>'
title="Delete">
<i class="fa fa-trash" style="font-size: 24px; color: #9c9798;"></i>
</a>
<%} %>
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
But i cannot access the id Label1 in the if loop. can anyone help me please
You can achieve this in code behind:
<asp:Repeater runat="server" ID="Repeater1" OnItemDataBound="Repeater1_ItemDataBound">
<ItemTemplate>
<tr role="row" class="odd">
<td><asp:Label ID="Label1" runat="server" Text='<%# Eval("strRoles") %>'></asp:Label></td>
<td>
<asp:HyperLink ID="Hyp1" runat="server" href="#modal-danger" data-toggle="modal" title="Delete" Visible="False">
<i class="fa fa-trash" style="font-size: 24px; color: #9c9798;"></i>
</asp:HyperLink>
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e) {
Label Label1 = e.Item.FindControl("Label1");
HyperLink Hyp1 = e.Item.FindControl("Hyp1");
int intProjectId = e.Item.DataItem("intProjectId");
if ((Label1.Text == "Creator")) {
Hyp1.Visible = true;
Hyp1.Attributes.Add("onclick", ("saveID(" + intProjectId + ")"));
}
}
I am using repeater and I want to find the label control in my repeater. here is my code
<asp:Repeater ID="friendRepeater" runat="server">
<table cellpadding="0" cellspacing="0">
<ItemTemplate>
<tr style=" width:700px; height:120px;">
<td>
<div style=" padding-left:180px;">
<div id="leftHandPost" style="float:left; width:120px; height:120px; border: medium solid #cdaf95; padding-top:5px;">
<div id="childLeft" style=" padding-left:5px;">
<div id="photo" style=" border: thin solid black; width:100px;height:100px;">
<asp:Image id="photoImage" runat="server" ImageUrl='<%# String.Concat("Images/", Eval("Picture")) %>' Width="100px" Height="100px" />
</div>
</div><!--childLeft-->
</div><!--leftHandPost-->
</div>
</td>
<td>
<div id="rightHandPost" style=" float:right; padding-right:260px;">
<div id="childRight" style="width:400px; height:120px; border: medium solid #cdaf95; padding-top:5px; padding-left:10px;">
<strong><asp:Label id="lblName" runat="server"><%# Eval("PersonName") %></asp:Label></strong><br />
<div style=" float:right; padding-right:10px;"><asp:Button runat="server" Text="Add" onClick="add" /></div><br />
<asp:Label id="lblID" runat="server"><%# Eval("PersonID") %></asp:Label><br />
<asp:Label id="lblEmail" runat="server"><%# Eval("Email") %></asp:Label>
</div><!--childRight-->
</div><!--rightHandPost-->
</td>
</tr>
</ItemTemplate>
<AlternatingItemTemplate>
<tr style=" width:700px; height:120px;">
<td>
<div style=" padding-left:180px;">
<div id="Div1" style="float:left; width:120px; height:120px; border: medium solid #cdaf95; padding-top:5px;">
<div id="Div2" style="padding-left:5px;">
<div id="Div3" style=" border: thin solid black; width:100px;height:100px;">
<asp:Image id="photoImage" runat="server" ImageUrl='<%# String.Concat("Images/", Eval("Picture")) %>' Width="100px" Height="100px" />
</div>
</div><!--childLeft-->
</div><!--leftHandPost-->
</div>
</td>
<td>
<div id="Div4" style=" float:right; padding-right:260px;">
<div id="Div5" style="width:400px; height:120px; border: medium solid #cdaf95; padding-top:5px; padding-left:10px;">
<strong><asp:Label id="lblName" runat="server"><%# Eval("PersonName")%></asp:Label></strong>
<div style=" float:right; padding-right:10px;"><asp:Button id="btnAdd" runat="server" Text="Add" onClick="add"></asp:Button></div><br />
<br />
<asp:Label id="lblID" runat="server"><%# Eval("PersonID") %></asp:Label><br />
<asp:Label id="lblEmail" runat="server"><%# Eval("Email") %></asp:Label>
</div><!--childRight-->
</div><!--rightHandPost-->
</td>
</tr>
</AlternatingItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
Here is the code behind for the add button.
protected void add(object sender, EventArgs e)
{
DateTime date = DateTime.Now;
System.Web.UI.WebControls.Label la = (System.Web.UI.WebControls.Label)friendRepeater.FindControl("PersonID");
String id = la.Text;
try
{
MySqlConnection connStr = new MySqlConnection();
connStr.ConnectionString = "Server = localhost; Database = healthlivin; Uid = root; Pwd = khei92;";
String insertFriend = "INSERT INTO contactFriend(friendID, PersonID, PersonIDB, date) values (#id, #personIDA, #personIDB, #date)";
MySqlCommand cmdInsertStaff = new MySqlCommand(insertFriend, connStr);
cmdInsertStaff.Parameters.AddWithValue("#id", "F000004");
cmdInsertStaff.Parameters.AddWithValue("#personIDA", "M000001");
cmdInsertStaff.Parameters.AddWithValue("#personIDB", id);
cmdInsertStaff.Parameters.AddWithValue("#date", date);
connStr.Open();
cmdInsertStaff.ExecuteNonQuery();
MessageBox.Show("inserted");
connStr.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
I have get the error of Object reference not set to an instance of an object. I think is because there are no value in the Label. The Find Control are not working. May I know how can fix this problem? Thank you very much
foreach (RepeaterItem item in friendRepeater.Items)
{
Label lab = item.FindControl("lblName") as Label;
}
I think you can use this:
var personId= (Label)friendRepeater.Items[0].FindControl("PersonID");
The problem is you don't have any Label names "personID", so it couldn't find that control.
I assume that you want to get value from this line
<asp:Label id="lblID" runat="server"><%# Eval("PersonID") %></asp:Label>
And this Label control names "lblID", so your query code should be
System.Web.UI.WebControls.Label la = (System.Web.UI.WebControls.Label)friendRepeater.FindControl("lblID");
Use lblID to find control instead of PersonID
This worked for me.
Label lblperson = (Label)(rpfrndRepeater.Items[0]).FindControl("lblPerson");
Hi I am building an online sports goods shop,
I have this plan of loading in all Sports Type in the Home page, like Football,Cricket,Basketball etc
And the administrator can create a game at his own will,
Here's the confusion
How do I display the SubCategories of each Game if clicked (inside the repeater).
I thought of adding an ImageButton to it!! But then how do I link that Image Button to the games, i.e. when the user clicks the respective Image button -> The subcategories of that game should be displayed
For example:
1. If I have games such as Cricket,Football etc.
2. The Repeater should show all the games in the repeater
3. When The User clicks on for instance Cricket
4. I wish to load all subcategories of cricket goods such as the BAT,BALL,STUMPS etc.
I attempted this by loading the games in Repeater as shown in below code snippet:
<asp:Repeater ID="RepDetails" runat="server"
ondatabinding="RepDetails_DataBinding">
<HeaderTemplate>
<table style="border: 1px solid #df5015; width: 500px" cellpadding="0">
<tr style="background-color: #df5015; color: White">
<td colspan="2">
<b>Type of Sports</b>
</td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr style="background-color: #EBEFF0">
<td>
<table style="background-color: #EBEFF0; border-top: 1px dotted #df5015; width: 500px">
<tr>
<td>
<asp:Label ID="Label1" runat="server" Text='<%#Eval("Id") %>' />
</td>
<td>
<asp:Label ID="lblSubject" runat="server" Text='<%#Eval("Category") %>' Font-Bold="true" />
</td>
<td>
<asp:ImageButton ID="ImageButton1" runat="server" OnClick="ImageButton2_Click" />
</td>
</tr>
</table>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
I've even added the ImageButton but confused about making it load the respective subcategories of that game!
Suggestions are welcome if there can be another work around which can be more effective..
You could try a nested repeater
In aspx
<asp:Repeater ID="RepDetails" runat="server" OnDataBinding="RepDetails_DataBinding">
<HeaderTemplate>
<table style="border: 1px solid #df5015; width: 500px" cellpadding="0">
<tr style="background-color: #df5015; color: White">
<td colspan="2">
<b>Type of Sports</b>
</td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr style="background-color: #EBEFF0">
<td>
<table style="background-color: #EBEFF0; border-top: 1px dotted #df5015; width: 500px">
<tr>
<td>
<asp:Label ID="Label1" runat="server" Text='<%#Eval("Id") %>' />
</td>
<td>
<asp:Label ID="lblSubject" runat="server" Text='<%#Eval("Category") %>' Font-Bold="true" />
</td>
<td>
<asp:ImageButton ID="ImageButton1" runat="server" OnClick="ImageButton2_Click" />
</td>
</tr>
</table>
</td>
</tr>
<asp:Repeater ID="SportsProps" runat="server">
<ItemTemplate>
<tr style="background-color: #EBEFF0">
<td>
<table style="background-color: #EBEFF0; border-top: 1px dotted #df5015; width: 500px">
<tr>
<td>
<asp:Label ID="lblSubject" runat="server" Text='<%#Eval("Name") %>' Font-Bold="true" />
</td>
<td>
<asp:ImageButton ID="ImageButton3" runat="server" OnClick="ImageButton3_Click" />
</td>
</tr>
</table>
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
In code behind
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
RepDetails.DataSource = GetData();
RepDetails.DataBind();
}
}
protected void ImageButton2_Click(object sender, ImageClickEventArgs e)
{
Repeater repeater = ((ImageButton)sender).NamingContainer.FindControl("SportsProps") as Repeater;
Label catLabel = ((ImageButton)sender).NamingContainer.FindControl("lblSubject") as Label;
repeater.DataSource = GetDataDetail(catLabel.Text);
repeater.DataBind();
}
protected void ImageButton3_Click(object sender, ImageClickEventArgs e)
{
//do something to hide the
}
private DataTable GetData()
{
DataTable dt = new DataTable();
dt.Columns.Add("id", typeof(string));
dt.Columns.Add("category", typeof(string));
dt.Rows.Add("1 ", "Basketball");
dt.Rows.Add("2 ", "Football");
dt.Rows.Add("3 ", "Soccer");
return dt;
}
private DataTable GetDataDetail(string category)
{
DataTable dt = new DataTable();
dt.Columns.Add("name", typeof(string));
dt.Rows.Add("Bat");
dt.Rows.Add("Ball");
dt.Rows.Add("Stump");
return dt;
}
I have a webpage that is setup like so:
There is a ListView that has an item for each record in one of our SQL tables. Each of these items has a CollapsiblePanel in it that can be expanded to show more detail about the given record.
My Issue:
When I expand one panel and then wait for it to complete...everything is okay. However, if I try to expand multiple of those collapsiblepanels at once (meaning before the first panel is completely expanded)...only the last panel expands showing its data.
My Question:
Is it possible to have each of these panels expand asynchronously? Seems silly that I have to wait for one panel to extend before I can extend another.
My aspx:
I modified this aspx a little bit by removing unneeded code to make it less confusing.
<asp:UpdatePanel ID="UpdPnlBGList" runat="server" ChildrenAsTriggers="true" UpdateMode="Conditional">
<ContentTemplate>
<div class="content-box">
<asp:Panel ID="pnlBGResult" runat="server">
<asp:ListView ID="lvSummary" runat="server" ItemPlaceholderID="placeholderBGList"
OnItemDataBound="lvSummary_ItemDataBound" OnItemCommand="lvSummary_ItemCommand">
<LayoutTemplate>
<table runat="server" id="tblList" cellpadding="0" cellspacing="0" border="0" style="table-layout: fixed;">
<tr id="placeholderBGList" runat="server">
</tr>
</table>
</LayoutTemplate>
<ItemTemplate>
<tr runat="server">
<td>
<asp:UpdatePanel ID="UpdBgItemTemplate" runat="server" ChildrenAsTriggers="true"
UpdateMode="Conditional">
<ContentTemplate>
<div class="bgList">
<asp:Panel ID="pnlSummary" runat="server">
<table id="tblBgList" runat="server" cellpadding="0" cellspacing="0" border="0" style="border-collapse: collapse;
border-spacing: 0px;">
<tr>
<td class="imageColumn">
<asp:ImageButton ID="imgCollapsible" CssClass="first" ImageUrl="~/Images/branding/plus.gif"
runat="server" CommandName="ExpandCollapse" Style="cursor: pointer; padding-right: 5px;" />
</td>
<td width="600px">
<asp:Label ID="lblBGName" runat="server" Text='<%# Eval("BGName")%>' CssClass="bgName"></asp:Label>
<asp:Label ID="lblDatePosted" runat="server" CssClass="datePosted"></asp:Label>
</td>
<td colspan="2">
<div style="float: right;">
<asp:Label ID="lblAccountNumber" runat="server" CssClass="accountReview"></asp:Label>
<asp:Label ID="lblAccountNumberText" runat="server" CssClass="accountReview"></asp:Label>
</div>
</td>
</tr>
<tr>
<td>
</td>
<td width="600px">
<asp:Label ID="lblBillToAddress" runat="server" Text='<%# Eval("BillToAddress")%>'
CssClass="billToAddress" Style="font-weight: bold;"></asp:Label>
</td>
<td>
<div style="float: right;">
<asp:ImageButton ID="imgViewAuthLetter" ImageUrl="~/Images/branding/document.jpeg"
CssClass="first" runat="server" OnClick="imgViewAuthLetter_Click" />
<asp:LinkButton ID="lnkAuthorizationLetter" runat="server" Text="View authorization letter"
class="link_button" OnClick="lnkAuthorizationLetter_Click" OnClientClick="dirtySuppress();"
OnPreRender="addTrigger_PreRender" />
</div>
</td>
<td width="70px" style="float: right;">
<div style="float: right;">
<asp:HyperLink ID="lnkExportImage" runat="server" ImageUrl="/Images/branding/export.jpg"
CssClass="hiperlinkExport" OnClick="dirtySuppress();" />
<asp:HyperLink ID="lnkExportText" runat="server" Text="Export" CssClass="hiperlinkExport"
OnClick="dirtySuppress(); precheckURL(this.href); return false;" />
</div>
</td>
</tr>
<tr>
<td colspan="4" style="padding: 0px;">
<asp:Panel Style="margin-left: 50px;" ID="pnlDetails" runat="server">
<of:AccountNumberListControl ID="accountNumberList" runat="server"></of:AccountNumberListControl>
</asp:Panel>
<cc1:CollapsiblePanelExtender ID="cpe" runat="Server" TargetControlID="pnlDetails"
CollapsedSize="0" Collapsed="True" ExpandControlID="imgCollapsible" CollapseControlID="imgCollapsible"
AutoCollapse="False" AutoExpand="False" ScrollContents="false" ImageControlID="imgCollapsible"
ExpandedImage="~/Images/branding/minus.gif" CollapsedImage="~/Images/branding/plus.gif"
ExpandDirection="Vertical" />
</td>
</tr>
<tr>
<td>
</td>
<td colspan="3" style="padding: 0px;">
<div class="itemSeperator" id="divItemSeperator" runat="server">
</div>
</td>
</tr>
</table>
</asp:Panel>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</td>
</tr>
</ItemTemplate>
</asp:ListView>
<asp:HiddenField ID="hdfAccountNumberListControlID" runat="server" Value="" />
<asp:HiddenField ID="hdfAccountNumerID" runat="server" Value="" />
</asp:Panel>
</div>
<of:CustomerSetupExportPopInControl ID="customerSetupExportPopIn" runat="server" />
</ContentTemplate>
My codebehind:
This is the code that is executed when you expand the panel. There are several controls that is populated.
private void ExpandBillingGroup(ListViewDataItem item)
{
Label accountNumberLabel;
Label accountNumberText;
HtmlControl itemSeperator;
AccountNumberListControl accountNumberList;
// set properties for fedex account number label and text.
accountNumberLabel = (Label)item.FindControl("lblAccountNumber");
accountNumberLabel.Text = "FedEx account number: ";
accountNumberLabel.CssClass = "fedExAccountNumberLabel";
accountNumberText = (Label)item.FindControl("lblAccountNumberText");
accountNumberText.Text = lvSummary.DataKeys[item.DisplayIndex].Values["FedExAccountNumber"].ToString();
accountNumberText.CssClass = "fedExAccountNumberText";
//set the properties for Export
var lnkExportImage = (HyperLink)item.FindControl("lnkExportImage");
lnkExportImage.Visible = true;
var lnkExportText = (HyperLink)item.FindControl("lnkExportText");
lnkExportText.Visible = true;
//When expanded populate Customer Setup Export control
customerSetupExportPopIn.BillingGroupID = lvSummary.DataKeys[item.DisplayIndex].Values["BillingGroupID"].ToString();
//When expanded populate AccountNumberlistControl
accountNumberList = (AccountNumberListControl)item.FindControl("accountNumberList");
if (accountNumberList != null)
{
//since we make the AccountNumberListControl not visible on collapse we have to make it visible when we expand
accountNumberList.Visible = true;
//Set the properties
accountNumberList.BillingGroupID = lvSummary.DataKeys[item.DisplayIndex].Values["BillingGroupID"].ToString();
accountNumberList.FedExAccountNumber = lvSummary.DataKeys[item.DisplayIndex].Values["FedExAccountNumber"].ToString();
accountNumberList.BillingGroupName = ((Label)lvSummary.Items[item.DisplayIndex].FindControl("lblBGName")).Text;
accountNumberList.BillToAddress = ((Label)lvSummary.Items[item.DisplayIndex].FindControl("lblBillToAddress")).Text;
accountNumberList.FirstItemNeedsToExpand = BillingGroupIsResolved;
accountNumberList.GetListOfAccountNumbers(lvSummary.DataKeys[item.DisplayIndex].Values["BillingGroupID"].ToString(), VendorID);
}
//set the properties for itemSepeartor
itemSeperator = (HtmlControl)item.FindControl("divItemSeperator");
itemSeperator.Attributes.Add("class", "itemSeperatorExpanded");
UpdatePanel upd = (UpdatePanel)item.FindControl("UpdBgItemTemplate");
upd.Update();
}
Thanks,
Holt
EDIT: Fixed grammar and title issues
I have the following Repeater:
<asp:Repeater ID="RptLeaveRequests" runat="server"
onitemdatabound="RptLeaveRequests_ItemDataBound">
<ItemTemplate>
<table id="tableItem" runat="server">
<tr>
<td style="width: 100px;">
<asp:Label ID="lblDate" runat="server" Text='<%#Eval("Date", "{0:dd/M/yyyy}") %>'></asp:Label>
</td>
<td style="width: 100px;">
<asp:Label ID="lblHours" runat="server" Text='<%#Eval("Hours") %>'></asp:Label>
</td>
<td style="width: 200px;">
<asp:Label ID="lblPeriod" runat="server" Text='<%#Eval("AMorPM") %>'></asp:Label>
</td>
<td style="width: 200px; font-size:10px;">
<asp:Label ID="lblNote" runat="server" Text='<%#Eval("Note") %>'></asp:Label>
</td>
<td style="50px">
<asp:RadioButtonList ID="rbtVerified" runat="server" >
<asp:ListItem Value="1">Accept</asp:ListItem>
<asp:ListItem Value="2">Reject</asp:ListItem>
</asp:RadioButtonList>
</td>
<td>
<asp:TextBox ID="txtNotes" runat="server" ></asp:TextBox>
</td>
</tr>
</table>
</ItemTemplate>
</asp:Repeater>
Am I trying to loop through each item, find one where the radio button is checked. If a radio button is checked i want to then check its value (Accept or Reject) and retrieve the data (Eval Date,Hours etc) and send it to another method to add to the database.
Can you please help me out, code so far:
protected void btnSubmit_Click(object sender, EventArgs e)
{
foreach (RepeaterItem item in RptLeaveRequests.Items)
{
}
}
You use <asp:RadioButtonList> , but in your code behind , you cast as RadioButton .
Try likes this ,
foreach (RepeaterItem item in RptLeaveRequests.Items)
{
var rdbList = item.FindControl("rbtVerified") as RadioButtonList;
switch(rdbList.SelectedValue)
{
case "1":
//Accept
break;
case "2":
//Reject
break;
}
}