how to use listview values

Posted by Priti2010 under ASP.NET on 11/2/2011 | Points: 10 | Views : 1232 | Status : [Member] | Replies : 1
<asp:ListView ID="ListView1" runat="server" DataKeyNames="Service_ID"
DataSourceID="SqlDataSource3" InsertItemPosition="FirstItem"
ItemPlaceholderID="Placeholder1" Visible="False">
<LayoutTemplate>
<table ID="table1" runat="server" border="1" width=100%>
<tr>
<th class="subheader" colspan="3">
Services</th>
<th>
<asp:LinkButton ID="lnkService" runat="server"></asp:LinkButton>
</th>
</tr>
<tr ID="Placeholder1" runat="server">
</tr>
</table>
</LayoutTemplate>
<ItemTemplate>
<tr>
<td>
<%#Eval("Service_Name")%>
</td>
<td>
<asp:CheckBox ID="chkService" runat="server" />
</td>
<td>
<asp:TextBox ID="txtServices" runat="server"></asp:TextBox>
</td>
</tr>
</ItemTemplate>
<InsertItemTemplate>
<asp:LinkButton ID="Link1" runat="server" Text="Edit"></asp:LinkButton>
</InsertItemTemplate>
</asp:ListView><asp:DataPager runat="server" ID="DataPager1" PagedControlID="ListView1"
Visible="False">
<Fields>
<asp:NumericPagerField />
</Fields>
</asp:DataPager><asp:DropDownList ID="ddlServer" runat="server" CssClass="dropdownlistLarge" Font-Size="10"
AutoPostBack="true" OnSelectedIndexChanged="ddlServer_SelectedIndexChanged" DataTextField="Server_Name"
DataValueField="Server_ID" DataSourceID="SqlDataSource1">
</asp:DropDownList>

how to access listview items on dropdown selection where in i can insert values into checkbox and textbox in listview and the same to be bind to a particular column of a gridview

Thanks & Regards
Priti



Responses

Posted by: Jiji on: 11/3/2011 [Member] Starter | Points: 25

Up
0
Down
just write itemcommand event of listview





if (e.Item.ItemType == ListViewItemType.DataItem)
{
Label lblId = (Label)e.Item.FindControl("lblId");
Label lblName = (Label)e.Item.FindControl("lblName");
Label lblCode = (Label)e.Item.FindControl("lblCode");
Label lblContactAddres1 = (Label)e.Item.FindControl("lblContactAddres1");
Label lblContactAddres2 = (Label)e.Item.FindControl("lblContactAddres2");
Label lblNationality = (Label)e.Item.FindControl("lblNationality");
Label lblMobile = (Label)e.Item.FindControl("lblMobile");
Label lblCity = (Label)e.Item.FindControl("lblCity");
Label lblFax = (Label)e.Item.FindControl("lblFax");
Label lblEmail = (Label)e.Item.FindControl("lblEmail");
Label lblRemarks = (Label)e.Item.FindControl("lblRemarks");
Label lblPhoto = (Label)e.Item.FindControl("lblPhoto");
Label lblAccountLedgerID = (Label)e.Item.FindControl("lblAccountLedgerID");
Label lblAreaID = (Label)e.Item.FindControl("lblAreaID");
Label lblProvinceID = (Label)e.Item.FindControl("lblProvinceID");
Label lblPriceCategoryID = (Label)e.Item.FindControl("lblPriceCategoryID");
Label lblPhone = (Label)e.Item.FindControl("lblPhone");
Session["CustomerPhoto"] = lblPhoto.Text;
Session["CustomerOrVendorID"] = lblId.Text;
switch (e.CommandName)
{

case "Edit":
{
ClearDataOfControls();
// For User Permission ( Security Module Use)
// OperationMode = "Edit";
_OperationMode = "E";
// For User Permission ( Security Module Use)
lblFunction.Text = "[ EDIT ]";
txtCustomerName.Text = lblName.Text;
txtAddress1.Text = lblContactAddres1.Text;
txtAddress2.Text = lblContactAddres2.Text;
txtCity.Text = lblCity.Text.Trim();
txtCustomerCode.Text = lblCode.Text.Trim();
txtEmail.Text = lblEmail.Text.Trim();
txtFax.Text = lblFax.Text.Trim();
txtMobile.Text = lblMobile.Text.Trim();
txtRemarks.Text = lblRemarks.Text.Trim();
txtPhone.Text = lblPhone.Text.Trim();
ddlAccountLedger.SelectedValue = lblAccountLedgerID.Text;
ddlArea.SelectedValue = lblAreaID.Text;
ddlListPrice.SelectedValue = lblPriceCategoryID.Text;
ddlProvince.SelectedValue = lblProvinceID.Text;
ddlNationality.SelectedValue = lblNationality.Text;
mpeCustomer.Show();
break;
}
}
}

Priti2010, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response