update data In Repeater Control Using Button Outside It - asp.net

I am having 5 div tags,in each div tag I am having repeater control.I want to allow user update information if he want.So on form load,I am retrieving all information from table,so one can update information.But I am unable to do this.I am giving the code for 3 repeater control.I tried this on button update click.Problem is when i clicked on update button it is not loop through first 4 repeater's for each loop,it just loop through the last for each loop.And I have created store procedure to update information.So,I want to send all parameters to it like:
enter code here
ob.UpdateProfile(profileid, candiid, pheadline, ethnicity, religion, caste, starsign, purpose, maritalstatus, lang, htid, height, wt, skincolor, eyesight, abtme, diet, drink, smoking, drug, frndship, schoolname, schpassyr, collegename, collgpassyr, compwebsite);
enter code here
foreach (RepeaterItem repItem in repProfileInfo.Items)
{
TextBox tProfileHeadline = repItem.FindControl("txtProfileHeadline") as TextBox;
pheadline = tProfileHeadline.Text;
DropDownList ddlEthnicity = repItem.FindControl("drpEthnicity") as DropDownList;
ethnicity = ddlEthnicity.SelectedItem.Text;
DropDownList ddlReligion = repItem.FindControl("drpReligion") as DropDownList;
religion = ddlReligion.SelectedItem.Text;
TextBox tCaste = repItem.FindControl("txtCaste") as TextBox;
caste = tCaste.Text;
DropDownList ddlStarSign = repItem.FindControl("drpStarSign") as DropDownList;
starsign = ddlStarSign.SelectedItem.Text;
DropDownList ddlPurpose = repItem.FindControl("drpPurpose") as DropDownList;
purpose = ddlPurpose.SelectedItem.Text;
DropDownList ddlMaritalStatus = repItem.FindControl("drpMaritalStatus") as DropDownList;
maritalstatus = ddlMaritalStatus.SelectedItem.Text;
TextBox tLanguage = repItem.FindControl("txtLanguage") as TextBox;
lang = tLanguage.Text;
TextBox tSchoolName = repItem.FindControl("txtSchoolName") as TextBox;
schoolname = tSchoolName.Text;
DropDownList ddlSchoolPassYr = repItem.FindControl("drpSchoolPassYr") as DropDownList;
schpassyr = ddlSchoolPassYr.SelectedItem.Text;
TextBox tCollegeName = repItem.FindControl("txtCollegeName") as TextBox;
collegename = tCollegeName.Text;
DropDownList ddlCollegePassYr = repItem.FindControl("drpCollegePassYr") as DropDownList;
collgpassyr = ddlCollegePassYr.SelectedItem.Text;
TextBox tCompanyWebsite = repItem.FindControl("txtCompanyWebsite") as TextBox;
compwebsite = tCompanyWebsite.Text;
}
foreach(RepeaterItem repItem1 in repPhysicalInfo.Items)
{
DropDownList ddlHeight = repItem1.FindControl("drpHeight") as DropDownList;
htid =ddlHeight.SelectedValue;
height = ddlHeight.SelectedItem.Text;
TextBox tWeight = repItem1.FindControl("txtWeight") as TextBox;
wt = tWeight.Text;
DropDownList ddlSkinColor = repItem1.FindControl("drpSkinColor") as DropDownList;
skincolor = ddlSkinColor.SelectedItem.Text;
DropDownList ddlEyeSight = repItem1.FindControl("drpEyeSight") as DropDownList;
eyesight = ddlEyeSight.SelectedItem.Text;
}
foreach(RepeaterItem repItem2 in repAbootMe.Items)
{
TextBox tAboutMe = repItem2.FindControl("txtAboutMe") as TextBox;
abtme = tAboutMe.Text;
CheckBox chkFriendShip = repItem2.FindControl("chkActivateFriendship") as CheckBox;
if (chkFriendShip.Checked == true)
frndship = "Yes";
else
frndship = "No";
}
As it is loop through the last for each loop,I am getting error in procedure,as it is not getting all its parameter.Variables I defined in first 4 repeater control loop,getting null value.So I want know how I can get information in all repeater controls,so i can update it.Give me any solution for this.Thanks in advance.
Design code of web form:
Height:
' Width="150px">
4.10
4.11
5.0
5.1
5.2
5.3
5.4
5.5
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="directorytdWidth">
Weight
</td>
<td class="directoryTdPadding">
<asp:TextBox ID="txtWeight" runat="server" Text='<%#Eval("wt") %>' Width="150px"></asp:TextBox>
</td>
</tr>
<tr>
<td class="directorytdWidth">
Skin Color:
</td>
<td class="directoryTdPadding">
<asp:TextBox ID="txtSkinColor" runat="server" Text='<%#Eval("skincolor")%>' Width="150px"></asp:TextBox>
<asp:DropDownList ID="drpSkinColor" runat="server" Height="24px" Width="100px" Visible="false">
<asp:ListItem>Wheatish</asp:ListItem>
<asp:ListItem>Fair</asp:ListItem>
<asp:ListItem>Tan/Brown</asp:ListItem>
<asp:ListItem>Dark</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="directorytdWidth">
Eye Sight:
</td>
<td class="directoryTdPadding">
<asp:TextBox ID="txtEyeSight" runat="server" Text='<%#Eval("eyesight")%>' Width="150px"></asp:TextBox>
<asp:DropDownList ID="drpEyeSight" runat="server" Height="24px" Width="100px" Visible="false">
<asp:ListItem>Clear</asp:ListItem>
<asp:ListItem>Glasses</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table></FooterTemplate>
</asp:Repeater>
</div>
<div id="aboutMe" runat="server" visible="false" style="margin-left: 50px; display: block">
<asp:Repeater ID="repAbootMe" runat="server" OnItemDataBound="myAboutMe">
<HeaderTemplate>
<table>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td class="directorytdWidth">
About Me:
</td>
<td class="directoryTdPadding">
<asp:TextBox ID="txtAboutMe" runat="server" Text='<%#Eval("aboutMe")%>' Width="200px"
TextMode="MultiLine" Height="100px"></asp:TextBox>
</td>
</tr>
<tr>
<td class="directorytdWidth">
Active Friendship Zone:
</td>
<td class="directoryTdPadding">
<asp:TextBox ID="txtActiveFrndZone" runat="server" Text='<%#Eval("friendship")%>'
Width="100px"></asp:TextBox>
<asp:CheckBox ID="chkActivateFriendship" runat="server" Text="Activate My Friendship Zone Profile"
Checked="True" ForeColor="#000000" Visible="false" />
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table></FooterTemplate>
</asp:Repeater>
<div id="otherInfo" runat="server" visible="false" style="margin-left: 50px; display: block">
<asp:Repeater ID="repOtherInfo" runat="server" OnItemDataBound="myOtherInfo">
<HeaderTemplate>
<table>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td class="directorytdWidth">
Diet:
</td>
<td class="directoryTdPadding">
<asp:TextBox ID="txtDiet" runat="server" Text='<%#Eval("diet")%>' Width="150px"></asp:TextBox>
<asp:DropDownList ID="drpDiet" runat="server" Height="24px" Width="100px" Visible="false">
<asp:ListItem></asp:ListItem>
<asp:ListItem>Veg</asp:ListItem>
<asp:ListItem>Non-Veg</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="directorytdWidth">
Drink:
</td>
<td class="directoryTdPadding">
<asp:TextBox ID="txtDrink" runat="server" Text='<%#Eval("drink")%>' Width="150px"></asp:TextBox>
<asp:DropDownList ID="drpDrinks" runat="server" Height="24px" Width="100px" Visible="false">
<asp:ListItem></asp:ListItem>
<asp:ListItem>Don't Drink</asp:ListItem>
<asp:ListItem>Drink Socially</asp:ListItem>
<asp:ListItem>Drink like fish</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="directorytdWidth">
Smoke:
</td>
<td class="directoryTdPadding">
<asp:TextBox ID="txtSmoke" runat="server" Text='<%#Eval("smoke")%>' Width="150px"></asp:TextBox>
<asp:DropDownList ID="drpSmoking" runat="server" Height="24px" Width="100px" Visible="false">
<asp:ListItem></asp:ListItem>
<asp:ListItem>Don't Smoke</asp:ListItem>
<asp:ListItem>Smoke Socially</asp:ListItem>
<asp:ListItem>Smoker</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="directorytdWidth">
Drugs:
</td>
<td class="directoryTdPadding">
<asp:TextBox ID="txtDrug" runat="server" Text='<%#Eval("drug")%>' Width="150px"></asp:TextBox>
<asp:DropDownList ID="drpDrug" runat="server" Height="24px" Width="100px" Visible="false">
<asp:ListItem></asp:ListItem>
<asp:ListItem>No Drugs</asp:ListItem>
<asp:ListItem>Druggi</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table></FooterTemplate>
</asp:Repeater>
</div>
<div id="contactInfo" runat="server" visible="false" style="margin-left: 50px; display: block">
<asp:Repeater ID="repContactInfo" runat="server" OnItemDataBound="myContactInfo">
<HeaderTemplate>
<table>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td class="directorytdWidth">
First Name:
</td>
<td class="directoryTdPadding">
<asp:TextBox ID="txtFirstName" runat="server" Width="150px" Text='<%#Eval("firstName")%>'></asp:TextBox>
</td>
</tr>
<tr>
<td class="directorytdWidth">
Last Name:
</td>
<td class="directoryTdPadding">
<asp:TextBox ID="txtLastName" runat="server" Width="150px" Text='<%#Eval("lastName")%>'></asp:TextBox>
</td>
</tr>
<tr>
<td class="directorytdWidth">
Gender:
</td>
<td class="directoryTdPadding">
<asp:TextBox ID="txtGender" runat="server" Width="100px" Text='<%#Eval("gender")%>'></asp:TextBox>
<asp:RadioButtonList ID="radioGender" runat="server" RepeatColumns="2" Visible="false">
<asp:ListItem Text="Male" Value="M"></asp:ListItem>
<asp:ListItem Text="Female" Value="F"> </asp:ListItem>
</asp:RadioButtonList>
</td>
</tr>
<tr>
<td class="directorytdWidth">
Address:
</td>
<td class="directoryTdPadding">
<asp:TextBox ID="txtAdd" runat="server" Width="200px" Text='<%#Eval("candiAddress")%>'
TextMode="MultiLine" Height="75px"></asp:TextBox>
</td>
</tr>
<tr>
<td class="directorytdWidth">
Country:
</td>
<td class="directoryTdPadding">
<asp:TextBox ID="txtCountry" runat="server" Width="150px" Text='<%#Eval("countryName")%>'></asp:TextBox>
<asp:DropDownList ID="drpCountry" runat="server" Width="150px" Height="24px" Visible="false"
AutoPostBack="true" OnSelectedIndexChanged="drpCountry_SelectedIndexChanged">
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="directorytdWidth">
State:
</td>
<td class="directoryTdPadding">
<asp:TextBox ID="txtState" runat="server" Width="150px" Text='<%#Eval("stateName")%>'></asp:TextBox>
<asp:DropDownList ID="drpState" runat="server" Width="150px" Visible="false" Height="24px"
AutoPostBack="true" OnSelectedIndexChanged="drpState_SelectedIndexChanged">
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="directorytdWidth">
City:
</td>
<td class="directoryTdPadding">
<asp:TextBox ID="txtCity" runat="server" Width="150px" Text='<%#Eval("cityName")%>'></asp:TextBox>
<asp:DropDownList ID="drpCity" runat="server" Width="150px" Height="24px" Visible="false"
AutoPostBack="true">
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="directorytdWidth">
Postal Code:
</td>
<td class="directoryTdPadding">
<asp:TextBox ID="txtPostalCode" runat="server" Width="150px" Text='<%#Eval("pincode")%>'></asp:TextBox>
</td>
</tr>
<tr>
<td class="directorytdWidth">
Landline:
</td>
<td class="directoryTdPadding">
<asp:TextBox ID="txtLandline" runat="server" Width="150px" Text='<%#Eval("landline")%>'></asp:TextBox>
</td>
</tr>
<tr>
<td class="directorytdWidth">
Mobile Number:
</td>
<td class="directoryTdPadding">
<asp:TextBox ID="txtMobile" runat="server" Width="150px" Text='<%#Eval("mobile")%>'></asp:TextBox>
</td>
</tr>
<tr>
<td class="directorytdWidth">
Date of Birth:
</td>
<td class="directoryTdPadding">
<asp:TextBox ID="txtDob" runat="server" Width="150px" Text='<%#Eval("dob")%>'></asp:TextBox>
<asp:DropDownList ID="drpYear" runat="server" Visible="false" Height="24px" Width="80px"
AutoPostBack="true">
</asp:DropDownList>
<asp:DropDownList ID="drpMonth" runat="server" Height="24px" Width="80px" OnSelectedIndexChanged="drpMonth_SelectedIndexChanged"
AutoPostBack="true" Visible="false">
<asp:ListItem Value="1" Selected="True">January</asp:ListItem>
<asp:ListItem Value="2">February</asp:ListItem>
<asp:ListItem Value="3">March</asp:ListItem>
<asp:ListItem Value="4">April</asp:ListItem>
<asp:ListItem Value="5">May</asp:ListItem>
<asp:ListItem Value="6">June</asp:ListItem>
<asp:ListItem Value="7">July</asp:ListItem>
<asp:ListItem Value="8">August</asp:ListItem>
<asp:ListItem Value="9">September</asp:ListItem>
<asp:ListItem Value="10">October</asp:ListItem>
<asp:ListItem Value="11">November</asp:ListItem>
<asp:ListItem Value="12">December</asp:ListItem>
</asp:DropDownList>
<asp:DropDownList ID="drpDate" runat="server" Height="24px" Width="50px" Visible="false"
AutoPostBack="true">
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="directorytdWidth">
Email Address:
</td>
<td class="directoryTdPadding">
<asp:TextBox ID="txtEmail" runat="server" Width="150px" Text='<%#Eval("altEmail")%>'></asp:TextBox>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table></FooterTemplate>
</asp:Repeater>
</div>
<div style="text-align: center">
<asp:Button ID="btnUpdate" Text="Update" runat="server" CssClass="btnImage" OnClick="btnUpdate_Click" /></div>
</div>

Related

For Loop or Dim for getting a handle on data from a Datagrid in a Checkbox

I am currently trying to ' Loop ' through my DataGrid to check if the boxes that are ticked to be shown on another page that pretty much looks like my existing one.
I'm having trouble finding out how to actually do a ' loop ' as they are called I think as I am a slow learner in coding , am just looking for some guidance in how I would achieve this goal of actually getting a handle on the Data. Below is my code for the ASP.GridView & well there is no VB.NET code-behind as of such because well , am stuck & need pushing the right direction .
EDIT: Forgot to mention , why cant I do this from a Dim This As String?
<asp:DataList ID="DataList1" runat="server" DataSourceID="SqlDataSource1" Width="100%">
<HeaderTemplate>
<table width="100%" style="font-family: Verdana; font-size: 8pt" cellpadding="0"
cellspacing="0" border="1">
<tr align="left">
<th colspan="4">
Customer:
<asp:Label ID="Customer_lab" runat="server"></asp:Label>
</th>
<th colspan="4">
Quote:
<asp:Label ID="Quote_lab" runat="server"></asp:Label>
</th>
<th colspan="4">
Project:
<asp:Label ID="Project_lab" runat="server"></asp:Label></th>
</tr>
<tr>
<th></th>
<th>
CODE
</th>
<th>
DESCRIPTION
</th>
<th>
LENGTH
</th>
<th>
WIDTH
</th>
<th>
QTY
</th>
<th>
COST
</th>
<th>
£M2
</th>
<th>
£UNIT
</th>
<th>
SUPPLIER</th>
<th>
QTY</th>
<th>
DUE DATE</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<asp:CheckBox ID="ChkItem" runat="server" /></td>
<td style="width: 150px">
<asp:Label ID="Label1" runat="server" Text='<%# Eval("Code") %>'></asp:Label></td>
<td>
<asp:Label ID="Label2" runat="server" Text='<%# Eval("Description") %>'></asp:Label></td>
<td align="right">
<asp:Label ID="Label5" runat="server" Text='<%# Eval("Length") %>'></asp:Label></td>
<td align="right">
<asp:Label ID="Label6" runat="server" Text='<%# Eval("Width") %>'></asp:Label></td>
<td align="center">
<asp:Label ID="Label3" runat="server" Text='<%# Eval("Qty") %>'></asp:Label></td>
<td align="right">
<asp:Label ID="Label4" runat="server" Text='<%# Eval("Cost") %>'></asp:Label></td>
<td align="right">
<asp:Label ID="Label7" runat="server" Text='<%# Eval("M2") %>'></asp:Label></td>
<td align="right">
<asp:Label ID="Label8" runat="server" Text='<%# Eval("SHT") %>'></asp:Label></td>
<td>
<asp:DropDownList ID="DD1" Width="100%" runat="server" Font-Names="Verdana" Font-Size="8pt">
</asp:DropDownList></td>
<td align="left">
<asp:TextBox ID="Qty_Txt1" OnTextChanged="GetData" OnDataBinding='<%# Eval("Code") %>'
AutoPostBack="true" Width="80%" Font-Names="Verdana" Font-Size="8pt" runat="server"></asp:TextBox></td>
<td>
<asp:TextBox ID="Date1" Width="90%" Font-Names="Verdana" Font-Size="8pt" AutoPostBack="true" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td></td>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
<td align="center">
<b>
<asp:Label ID="New_Lab" Font-Size="8pt" runat="Server"></asp:Label></b></td>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
<asp:DropDownList ID="DD2" Width="100%" Font-Names="Verdana" Font-Size="8pt" runat="server">
</asp:DropDownList></td>
<td align="left">
<asp:TextBox ID="Qty_Txt2" AutoPostBack="true" Width="80%" Font-Names="Verdana"
Font-Size="8pt" runat="Server"></asp:TextBox></td>
<td>
<asp:TextBox ID="Date2" Width="90%" Font-Names="Verdana" Font-Size="8pt" runat="Server"></asp:TextBox></td>
</tr>
<tr>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
<asp:DropDownList ID="DD3" Width="100%" Font-Names="Verdana" Font-Size="8pt" runat="server">
</asp:DropDownList></td>
<td align="left">
<asp:TextBox ID="Qty_Txt3" AutoPostBack="true" Width="80%" Font-Names="Verdana"
Font-Size="8pt" runat="Server"></asp:TextBox></td>
<td width="8%">
<asp:TextBox ID="Date3" Width="90%" Font-Names="Verdana" Font-Size="8pt" runat="Server" ValidationGroup="PersonalInfoGroup">
</asp:TextBox>
<asp:CustomValidator id="RequiredFieldValidator1"
controltovalidate="Date3"
OnServerValidate="Date3_Validator"
errormessage="Date Error!"
runat="Server">
</asp:CustomValidator></td>
</tr>
<asp:HiddenField ID="Supplier" Value='<%# Eval("cdf_supplier_tx") %>' runat="server" />
<asp:HiddenField ID="PrefSupplier" Value='<%# Eval("cdf_supplier_pref") %>' runat="server" />
<asp:HiddenField ID="Nominal" Value='<%# Eval("Nominal") %>' runat="server" />
<asp:HiddenField ID="QuoteCost" Value='<%# Eval("QuoteCost") %>' runat="server" />
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
<SeparatorStyle BackColor="#C0FFFF" />
<SeparatorTemplate>
</SeparatorTemplate>
</asp:DataList>
EDIT: Some of the VB that's been tried and tested & A little of my own that G_Wilson has tried helping me with but i can't grasp on.
Protected Sub Save_Btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Save_Btn.Click
'connection.Open()
'command = New SqlCommand("Select * from impsod_h where [Quote Number]='" + HiddenQno.Value + "'", connection)
'datareader = command.ExecuteReader()
'If datareader.HasRows = False Then
' datareader.Close()
' CreateImpsod1()
' CreateIMPSOH1()
' installcalc()
'Else
' datareader.Close()
'End If
'connection.Close()
For Each Row As GridViewRow In GridView1.Rows
Dim ThisCheck As String
ThisCheck = ChkItem.Checked
Next
End Sub
What i think you will need is a For Each Loop.
That will look a little something like this :
For Each Row as GridViewRow in GridView1.Rows
Dim chkSelect as CheckBox
chkSelect = e.Row.FindControl("ChkItem")
If chkSelect.Checked = True Then
'Put vb.net logic here ...
Else
'Put anything else here ...
End If
Next
That should do the trick.

how to access controls inside asp repeater control

I am having form which allows user to update their profile and contact information.I have created this form using asp:repeater control inside a div tag.I am having 4 div tags inside that having repeater control which contains other controls such as text boxes and drop down list.I just want to know,how i can access controls inside repeater control.I am giving the code:
<tr>
<td class="directorytdWidth">
Gender:
</td>
<td class="directoryTdPadding">
<asp:TextBox ID="txtGender" runat="server" Width="100px" Text='<%#Eval("gender")%>'></asp:TextBox>
<asp:RadioButtonList ID="radioGender" runat="server" RepeatColumns="2" Visible="false">
<asp:ListItem Text="Male" Value="M"></asp:ListItem>
<asp:ListItem Text="Female" Value="F"> </asp:ListItem>
</asp:RadioButtonList>
</td>
</tr>
<tr>
<td class="directorytdWidth">
Address:
</td>
<td class="directoryTdPadding">
<asp:TextBox ID="txtAdd" runat="server" Width="200px" Text='<%#Eval("candiAddress")%>'
TextMode="MultiLine" Height="75px"></asp:TextBox>
</td>
</tr>
<tr>
<td class="directorytdWidth">
Country:
</td>
<td class="directoryTdPadding">
<asp:TextBox ID="txtCountry" runat="server" Width="150px" Text='<%#Eval("countryName")%>'></asp:TextBox>
<asp:DropDownList ID="drpCountry" runat="server" SelectedValue='<%#Eval("countryName")%>' Width="150px" Height="24px" Visible="false"
AutoPostBack="true" OnSelectedIndexChanged="drpCountry_SelectedIndexChanged">
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="directorytdWidth">
State:
</td>
<td class="directoryTdPadding">
<asp:TextBox ID="txtState" runat="server" Width="150px" Text='<%#Eval("stateName")%>'></asp:TextBox>
<asp:DropDownList ID="drpState" runat="server" SelectedeValue='<%#Eval("stateName")%>' Width="150px" Visible="false" Height="24px"
AutoPostBack="true" OnSelectedIndexChanged="drpState_SelectedIndexChanged">
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="directorytdWidth">
City:
</td>
<td class="directoryTdPadding">
<asp:TextBox ID="txtCity" runat="server" Width="150px" Text='<%#Eval("cityName")%>'></asp:TextBox>
<asp:DropDownList ID="drpCity" runat="server" Width="150px" Height="24px" Visible="false"
AutoPostBack="true">
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="directorytdWidth">
Postal Code:
</td>
<td class="directoryTdPadding">
<asp:TextBox ID="txtPostalCode" runat="server" Width="150px" Text='<%#Eval("pincode")%>'></asp:TextBox>
</td>
</tr>
<tr>
<td class="directorytdWidth">
Landline:
</td>
<td class="directoryTdPadding">
<asp:TextBox ID="txtLandline" runat="server" Width="150px" Text='<%#Eval("landline")%>'></asp:TextBox>
</td>
</tr>
<tr>
<td class="directorytdWidth">
Mobile Number:
</td>
<td class="directoryTdPadding">
<asp:TextBox ID="txtMobile" runat="server" Width="150px" Text='<%#Eval("mobile")%>'></asp:TextBox>
</td>
</tr>
<tr>
<td class="directorytdWidth">
Date of Birth:
</td>
<td class="directoryTdPadding">
<asp:TextBox ID="txtDob" runat="server" Width="150px" Text='<%#Eval("dob")%>'></asp:TextBox>
<asp:DropDownList ID="drpYear" runat="server" Visible="false" Height="24px" Width="80px"
AutoPostBack="true">
</asp:DropDownList>
<asp:DropDownList ID="drpMonth" runat="server" Height="24px" Width="80px" OnSelectedIndexChanged="drpMonth_SelectedIndexChanged"
AutoPostBack="true" Visible="false">
<asp:ListItem Value="1" Selected="True">January</asp:ListItem>
<asp:ListItem Value="2">February</asp:ListItem>
<asp:ListItem Value="3">March</asp:ListItem>
<asp:ListItem Value="4">April</asp:ListItem>
<asp:ListItem Value="5">May</asp:ListItem>
<asp:ListItem Value="6">June</asp:ListItem>
<asp:ListItem Value="7">July</asp:ListItem>
<asp:ListItem Value="8">August</asp:ListItem>
<asp:ListItem Value="9">September</asp:ListItem>
<asp:ListItem Value="10">October</asp:ListItem>
<asp:ListItem Value="11">November</asp:ListItem>
<asp:ListItem Value="12">December</asp:ListItem>
</asp:DropDownList>
<asp:DropDownList ID="drpDate" runat="server" Height="24px" Width="50px" Visible="false"
AutoPostBack="true">
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="directorytdWidth">
Email Address:
</td>
<td class="directoryTdPadding">
<asp:TextBox ID="txtEmail" runat="server" Width="150px" Text='<%#Eval("altEmail")%>'></asp:TextBox>
</td>
</tr>
In this I am having drop down selected index changed event,so how to fire this event
and also I want define functions which can be accessible in drop down event.Because when i define functions I am unable to get controls inside repeater control.So please give me any solution for this.Thanks in advance....
Not sure what controls do you want to access, but
1) make them runat="server" and give them ID
2) add event handler to repeater for ItemCreated, or ItemDataBound events
3) access control like this:
void R1_ItemCreated(Object Sender, RepeaterItemEventArgs e) {
var label = (Label)e.Item.FindControl("YourItemId")
}
you cannot access the dropdown events once they are in the repeater control. you can perform actions on buttons using CommandName and CommandArgumnent in ItemCommand event of repeater.
however you can do a workaround. bring the dropdown out of repeater , generate its SelectedIndexChanged event and AutoPostback="true". Then put back in repeater. Now in its event in code behind you can perform your operations. I once did this but this isn't good way.

Change my form Dropdown dynamically when changing value from main dropdown list

I have a drop-down list where i select value and when i select a value from it, a form will appear. In that form i have four drop-down list of currencies so when i select .UK in my Drop-down list all four dropdown list's in the form show GBP,and when i select .CA it show CAN in four drop-down list's present in the form. how can i do that?
My first drop-dwon list from where i select value to fill form:
<asp:DropDownList ID="ddlPortal" runat="server" AutoPostBack="True"
onselectedindexchanged="ddlPortal_SelectedIndexChanged">
<asp:ListItem>TRAVELONG</asp:ListItem>
<asp:ListItem>ONETRAVEL</asp:ListItem>
<asp:ListItem>.UK</asp:ListItem>
<asp:ListItem>.CA-YYZ</asp:ListItem>
<asp:ListItem>.CA-YVR</asp:ListItem>
</asp:DropDownList>
Dropdown list where i want changes:
<asp:ValidationSummary ID="vdm" runat="server" ForeColor="Red" />
<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"
onselectedindexchanged="ddlUnusedAmount_SelectedIndexChanged">
<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">
<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">
<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">
<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="Button1" runat="server" onclick="Button1_Click"
Text="Submit" />
</td>
</tr>
</table>
Thanks in advance..

File Uploader not working wnen used in ajax tab container with update panel

I am using ajax tab container with update panel and file uploader
fileuploaderId.HasFille always blank.
Here is my html code
<cc1:TabPanel ID="tour" runat="server">
<HeaderTemplate>
<span class="label_Tag_big">भ्रमण (Tours)</span></HeaderTemplate>
<ContentTemplate>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<center class="control_bg">
<table width="75%" cellspacing="1">
<tr>
<td style="background-color: #996666">
<table width="100%" align="center" cellpadding="0" cellspacing="1">
<tr class="form_heading">
<td colspan="2">
<asp:Label ID="lbl" runat="server" Text="भ्रमण (Tours)"></asp:Label>
</td>
</tr>
<tr class="bgColor" align="left" valign="top">
<td>
विभागाध्‍यक्ष / अधिकारी का पद नाम
</td>
<td>
designation location, department
</td>
</tr>
<tr class="bgColor" align="left" valign="top">
<td>
<asp:Label ID="lblCurrentTT" runat="server"></asp:Label>
का लक्ष्‍य
</td>
<td>
<asp:Label ID="lblTargetT" runat="server"></asp:Label>
</td>
</tr>
<tr class="bgColor" align="left" valign="top">
<td>
<asp:Label ID="lblCurrentTA" runat="server"></asp:Label>
की लक्ष्‍य प्राप्ति
</td>
<td>
<asp:Label ID="lblAchivedT" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td class="form_sub_heading" colspan="2" align="left">
भ्रमण का विवरण (Tours details)
</td>
</tr>
<tr class="bgColor" align="left" valign="top">
<td width="45%">
दौरे का स्थान
</td>
<td width="55%">
<table width="100%" cellpadding="3" cellspacing="0">
<tr>
<td width="50%">
<asp:DropDownList ID="ddlLocLevel" runat="server" OnSelectedIndexChanged="ddlLocLevel_SelectedIndexChanged"
AutoPostBack="True" Width="200px" />
<asp:RequiredFieldValidator ID="rfqLocLevel" runat="server" InitialValue="0" ControlToValidate="ddlLocLevel"
Display="None" ErrorMessage="दौरे का स्थान चुनें " ValidationGroup="tour"></asp:RequiredFieldValidator>
</td>
<td width="50%">
<asp:DropDownList ID="ddlLocation" runat="server" OnSelectedIndexChanged="ddlLocation_SelectedIndexChanged"
AutoPostBack="True" Width="200px">
<asp:ListItem Text="-- चुनें --" Value="0"></asp:ListItem>
</asp:DropDownList>
<asp:RequiredFieldValidator ID="rfqLocation" runat="server" InitialValue="0" ControlToValidate="ddlLocation"
Display="None" ErrorMessage="-- चुनें --" ValidationGroup="tour" Enabled="false"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<asp:DropDownList ID="ddlSubDistrict" runat="server" OnSelectedIndexChanged="ddlSubDistrict_SelectedIndexChanged"
AutoPostBack="True" Width="200px">
<asp:ListItem Text="-- तहसील चुनें --" Value="0"></asp:ListItem>
</asp:DropDownList>
<asp:RequiredFieldValidator ID="rfqddlSubDistrict" runat="server" InitialValue="0"
ControlToValidate="ddlSubDistrict" Display="None" ErrorMessage="-- चुनें --"
ValidationGroup="tour" Enabled="false"></asp:RequiredFieldValidator>
</td>
<td>
<asp:DropDownList ID="ddlPoliceStation" runat="server" Width="200px">
<asp:ListItem Text="-- पुलिस थाना चुनें --" Value="0"></asp:ListItem>
</asp:DropDownList>
<asp:RequiredFieldValidator ID="rfqddlPoliceStation" runat="server" InitialValue="0"
ControlToValidate="ddlPoliceStation" Display="None" ErrorMessage="-- पुलिस थाना चुनें --"
ValidationGroup="tour" Enabled="false"></asp:RequiredFieldValidator>
</td>
</tr>
</table>
</td>
</tr>
<tr class="bgColor" align="left" valign="top">
<td>
<asp:Label ID="lblTourStartDate" runat="server" Text="दौरे की तिथि "></asp:Label>
</td>
<td>
<asp:TextBox ID="txtTourStartDate" runat="server" Width="25%" CssClass="date" onkeypress="return false;"
onPaste="return false;"></asp:TextBox>
<cc1:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="txtTourStartDate"
Format="dd/MM/yyyy">
</cc1:CalendarExtender>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtTourStartDate"
ErrorMessage="दौरे की आरम्भिक तिथि डाले" ValidationGroup="tour" Display="None"></asp:RequiredFieldValidator>
से
<asp:TextBox ID="txtTourEndDate" runat="server" Width="25%" onkeypress="return false;"
onPaste="return false;"></asp:TextBox>
<cc1:CalendarExtender ID="CalendarExtender2" runat="server" TargetControlID="txtTourEndDate"
Format="dd/MM/yyyy">
</cc1:CalendarExtender>
तक
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtTourEndDate"
ErrorMessage="दौरे की समाप्ति तिथि डाले" ValidationGroup="tour" Display="None"></asp:RequiredFieldValidator>
</td>
</tr>
<tr class="bgColor" align="left" valign="top">
<td>
दौरे के दौरान निरीक्षण किया गया ?
</td>
<td>
<asp:RadioButtonList ID="rdbtnInsp" runat="server" RepeatDirection="Horizontal" AutoPostBack="true"
OnSelectedIndexChanged="rdbtnInsp_SelectedIndexChanged">
<asp:ListItem Text="नही" Value="0"></asp:ListItem>
<asp:ListItem Text="हाँ" Value="1"></asp:ListItem>
</asp:RadioButtonList>
</td>
</tr>
<tr class="bgColor" align="left" valign="top">
<td>
निरीक्षण नही किये जाने की स्थिति मे टिप्पणी
</td>
<td>
<asp:TextBox ID="txtConIns" runat="server" TextMode="MultiLine" MaxLength="4000"
Enabled="false" Rows="3" Width="97%"></asp:TextBox>
<asp:RequiredFieldValidator ID="rfqConIns" runat="server" ControlToValidate="txtConIns"
ValidationGroup="tour" ErrorMessage="निरीक्षण नही किये जाने की स्थिति मे टिप्पणी डाले "
Enabled="false" Display="None">
</asp:RequiredFieldValidator>
</td>
</tr>
<tr class="bgColor" align="left" valign="top">
<td>
दौरे के दौरान रात्री विश्राम किया गया ?
</td>
<td>
<asp:RadioButtonList ID="rdbtnNHault" runat="server" RepeatDirection="Horizontal"
AutoPostBack="true" OnSelectedIndexChanged="rdbtnNHault_SelectedIndexChanged">
<asp:ListItem Text="नही" Value="0"></asp:ListItem>
<asp:ListItem Text="हाँ" Value="1"></asp:ListItem>
</asp:RadioButtonList>
</td>
</tr>
<tr class="bgColor" align="left" valign="top">
<td>
रात्री विश्राम नही किये जाने की स्थिति मे टिप्पणी
</td>
<td>
<asp:TextBox ID="txtConNHault" runat="server" TextMode="MultiLine" MaxLength="4000"
Enabled="false" Rows="3" Width="97%"></asp:TextBox>
<asp:RequiredFieldValidator ID="rfqConNHault" runat="server" ControlToValidate="txtConNHault"
Display="None" ValidationGroup="tour" ErrorMessage="रात्री विश्राम नही किये जाने की स्थिति मे टिप्पणी डाले "
Enabled="false">
</asp:RequiredFieldValidator>
<asp:ValidationSummary ID="vsTour" runat="server" ShowSummary="False" ShowMessageBox="true"
ValidationGroup="tour" />
</td>
</tr>
<tr class="bgColor" align="left" valign="top">
<td>
<asp:Label ID="Label8" runat="server" Text="संलग्न निरीक्षण रिपोर्ट "></asp:Label>
</td>
<td>
<asp:FileUpload ID="fuTourReport" runat="server" />
<asp:RegularExpressionValidator ID="RegularExpressionValidator3" runat="server" ErrorMessage="Only pdf file is allowed!"
ValidationExpression="^.+(.pdf|.PDF)$" ControlToValidate="fuTourReport" Display="None"
ValidationGroup="nhalt"> </asp:RegularExpressionValidator>
</td>
</tr>
<tr class="bgColor" align="left" valign="top">
<td colspan="2" align="center">
<asp:Button ID="btnSaveTour" runat="server" Text="Submit" ValidationGroup="tour"
OnClick="btnSaveTour_Click" CssClass="savetour" />
<asp:Button ID="btnCancelTour" runat="server" Text="Cancel" CausesValidation="False" />
</td>
</tr>
</table>
</td>
</tr>
</table>
<center style="padding-top: 5px">
<asp:GridView ID="grdTours" runat="server" AllowPaging="True" AutoGenerateColumns="False"
DataKeyNames="tourId" Width="100%" OnPageIndexChanging="grdTours_PageIndexChanging"
OnRowCommand="grdTours_RowCommand">
<Columns>
<asp:BoundField DataField="Location_NameH" HeaderText="दौरे का स्थान " />
<asp:BoundField DataField="tourStartDate" HeaderText="आरम्‍भिक तिथि" DataFormatString="{0:dd/MM/yyyy}" />
<asp:BoundField DataField="tourEndDate" HeaderText="समाप्‍ति की तिथि" DataFormatString="{0:dd/MM/yyyy}" />
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="lnkinsdetail" runat="server" Text="Detail" CommandName="insdetail"
CommandArgument='<%#Eval("tourId")%>'></asp:LinkButton></ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</center>
</center>
</ContentTemplate>
</asp:UpdatePanel>
</ContentTemplate>
</cc1:TabPanel>
</cc1:TabContainer>
I have already tried this
<Triggers>
<asp:PostBackTrigger ControlID="clickButton" />
</Triggers>
and
protected void Page_Init(object sender, EventArgs e)
{
PostBackTrigger trig = new PostBackTrigger();
trig.ControlID = btnSaveTour.UniqueID;
UpdatePanel1.Triggers.Add(trig);
}
but no luck ....
Unfortunately, the FileUpload control doesn't work inside an UpdatePanel
You don't have many options really other than removing the UpdatePanel or looking at working around it by using something like the AsyncFileUpload control
See this answer for some more detail
Dave

asp.net listview and findcontrol

I have listview and i need to bind the dropdown list in the list view to ListItemCollection which will be built using a function BindPages().
When I clicked on the AddNew Link I am not able to bind the dropdown.
<asp:ListView DataKeyNames="Menuid" OnItemCommand="lvParentMenus_ItemCommand" OnSorting="lvParentMenus_Sorting"
OnDataBound="lvParentMenus_DataBound" DataSourceID="SqlDataSource1" ID="lvParentMenus"
runat="server">
<LayoutTemplate>
<table border="0" id="listview" width="100%" class="grid" cellpadding="0" cellspacing="0">
<thead>
<tr class="listingheader ">
<td width="10%" style="text-align: center; !important">
<input type="checkbox" name="checkbox" id="headercheck" />
</td>
<td id="thsno" runat="server">
<asp:LinkButton ID="LinkButton1" runat="server" CommandName="Sort" CommandArgument="Sno"
Text="Sno" />
</td>
<td id="thmenutext" runat="server">
<asp:LinkButton runat="server" ID="LinkButton2" Text="Menu Text" CommandName="Sort"
CommandArgument="MenuText" />
</td>
<td id="thmenuurl" runat="server">
<asp:LinkButton runat="server" ID="LinkButton3" Text="Menu Url" CommandName="Sort"
CommandArgument="MenuUrl" />
</td>
<td id="thlevel" runat="server">
<asp:LinkButton runat="server" ID="LinkButton4" Text="Level of Display" CommandName="Sort"
CommandArgument="level" />
</td>
<td>
Action
</td>
</tr>
</thead>
<tbody>
<tr runat="server" id="itemPlaceholder">
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="3" align="center">
<asp:Label ID="lblMessage" Text="dfdfdfd" runat="server"></asp:Label>
</td>
<td align="right">
<asp:LinkButton Text="Add New" ID="lnkNew" CommandName="FillDropDown" runat="server"
Font-Bold="true" OnClick="AddNew"></asp:LinkButton>
</td>
</tr>
</tfoot>
</table>
<ItemTemplate>
<tr class='<%# Container.DataItemIndex % 2 == 0 ? "lrow1" : "lrow1 altrow" %>'>
<td class="col1" align="center">
<asp:CheckBox runat="server" ID="chkitem"></asp:CheckBox>
</td>
<td class="lrow1">
<%# Eval("Sno")%>
<asp:HiddenField ID="hdnStoreID" runat="server" Value='<%# Eval("MenuId") %>' />
</td>
<td>
<%# Eval("MenuText")%>
</td>
<td>
<asp:DropDownList ID="ddlPagesList" runat="server" DataSource='<%#BindPages()%>'>
</asp:DropDownList>
</td>
<td>
<asp:DropDownList ID="ddlLevel" runat="server" DataSource='<%#BindLevel(6)%>' SelectedValue='<%# Eval("level")%>'>
</asp:DropDownList>
</td>
<td nowrap="nowrap">
<asp:LinkButton ID="lnkEdit" runat="server" CommandName="Edit">Edit</asp:LinkButton>
|
<asp:LinkButton ID="lnkdelete" runat="server" CommandName="Delete" OnClientClick="javascript:return confirm('Are you sure to delete the current item');">Delete</asp:LinkButton>
</td>
</tr>
</ItemTemplate>
<InsertItemTemplate>
<tr class="lrow1">
<td class="col1" align="center">
</td>
<td class="lrow1">
</td>
<td class="lrow1">
<asp:TextBox ID="txtMenuText" runat="server" Width="80px" Text='<%# Eval("MenuText")%>'
CssClass="inputbox" ValidationGroup="InsertFields" />
<asp:RequiredFieldValidator ID="reqValidCity" ControlToValidate="txtMenuText" runat="server"
ErrorMessage="City Name is required." Display="Dynamic" ValidationGroup="InsertFields">*</asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="regValidCity" runat="server" ErrorMessage="Please Enter Alphabets only."
Display="Dynamic" ValidationGroup="g1" ControlToValidate="txtMenuText" ValidationExpression="^[a-zA-Z0-9\s]{2,1000}"></asp:RegularExpressionValidator>
</td>
<td>
<asp:DropDownList ID="ddlPagesList" runat="server" DataSource='<%#BindPages()%>'>
</asp:DropDownList>
</td>
<td>
<asp:DropDownList ID="ddlLevel" runat="server" DataSourceID="sdsLevel" DataValueField="level"
DataTextField="level">
</asp:DropDownList>
</td>
<td nowrap="nowrap">
<asp:LinkButton ID="lnkinsert" runat="server" OnClick="lnkinsert_Click" ValidationGroup="InsertFields"> Insert</asp:LinkButton>
</td>
</tr>
</InsertItemTemplate>
</asp:ListView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" SelectCommand="usp_getParentMenus"
SelectCommandType="StoredProcedure">
<SelectParameters>
<asp:ControlParameter ControlID="ddlRoles" Name="intRoleid" PropertyName="Text" DefaultValue="1"
ConvertEmptyStringToNull="true" Direction="Input" />
</SelectParameters>
</asp:SqlDataSource>
and here is the method BindPAges()
protected ListItemCollection BindPages()
{
string sDir = Request.PhysicalApplicationPath;
if (FirstCount == 0)
DirSearch(sDir);
return collection;
}
When I tried to find the ddlPageList in the AddNew() method it is throwing error "Object referenc not set "
AddNEw() Method:
` protected void AddNew(object sender, EventArgs e)
{
lvParentMenus.InsertItemPosition = InsertItemPosition.FirstItem;
lvParentMenus.FindControl("lnkNew").Visible = false;
lvParentMenus.EditIndex = -1;
sdsLevel.ConnectionString = DBConnectionString.ConnectionString;
Parameter a = new Parameter("intRoleid", DbType.Int32);
a.DefaultValue = ddlRoles.SelectedValue.ToString();
sdsLevel.SelectParameters.Add(a);
sdsLevel.SelectCommand = "usp_getParentMenus";
DropDownList ddlpages = (DropDownList)lvParentMenus.FindControl("ddlPagesList");
string sDir = Request.PhysicalApplicationPath;
DirSearch(sDir);
ddlpages.DataSource = collection;
ddlpages.DataBind();
}
Need urgently.
Thanks.
Please try
DropDownList ddlpages = (DropDownList)lvParentMenus.Items[0].FindControl("ddlPagesList");
Have you tried to use runat=server property in TABLE in Listview?

Resources