I'm having a ListView in grid format which comprises headers as (NAME,ID,ADDRESS,GENDER,MOBILENO,PHOTO,BLOCK).
The BLOCK column consists a CheckBox in each row.
When the checkbox is checked in the BLOCK column, that particular row of the checkbox should be changed to ReadOnly, resulting in change of that particular row's backcolor.
my listview coding in aspx is...
<AlternatingItemTemplate>
<tr class="AITtr">
<td>
<asp:Label ID="NAMELabel" runat="server" Text='<%# Eval("NAME") %>' />
</td>
<td>
<asp:Label ID="IDLabel" runat="server" Text='<%# Eval("ID") %>' />
</td>
<td>
<asp:Label ID="ADDRESSLabel" runat="server" Text='<%# Eval("ADDRESS") %>' />
</td>
<td>
<asp:Label ID="GENDERLabel" runat="server" Text='<%# Eval("GENDER") %>' />
</td>
<td>
<asp:Label ID="MOBILENOLabel" runat="server" Text='<%# Eval("MOBILENO") %>' />
</td>
<td>
<asp:Image ID="Image1" runat="server" ImageUrl='<%#Eval("PHOTO") %>' Height="30" Width="30" />
</td>
<td>
<asp:CheckBox ID="BLOCKCheckBox" runat="server" Checked="false" Enabled="true" />
</td>
<td>
<asp:Button ID="DeleteButton" runat="server" CommandName="Delete" Text="Delete" BackColor="#577109" ForeColor="Black" BorderStyle="Solid" Font-Names="Copperplate Gothic Light" />
<asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Edit" BackColor="#577109" ForeColor="Black" BorderStyle="Solid" Font-Names="Copperplate Gothic Light"/>
</td>
</tr>
</AlternatingItemTemplate>
<EditItemTemplate>
<tr class="EITtr">
<td>
<asp:TextBox ID="NAMETextBox" runat="server" Text='<%# Bind("NAME") %>' />
</td>
<td>
<asp:Label ID="IDLabel1" runat="server" Text='<%# Eval("ID") %>' />
</td>
<td>
<asp:TextBox ID="ADDRESSTextBox" runat="server" Text='<%# Bind("ADDRESS") %>' />
</td>
<td>
<asp:TextBox ID="GENDERTextBox" runat="server" Text='<%# Bind("GENDER") %>' />
</td>
<td>
<asp:TextBox ID="MOBILENOTextBox" runat="server" Text='<%# Bind("MOBILENO") %>' />
</td>
<td>
<asp:TextBox ID="PHOTOTextBox" runat="server" Text='<%# Bind("PHOTO") %>' />
</td>
<td>
<asp:CheckBox ID="BLOCKCheckBox" runat="server" Checked="false" Enabled="true" />
</td>
<td>
<asp:Button ID="UpdateButton" runat="server" CommandName="Update"
Text="Update" BackColor="#577109" ForeColor="Black" BorderStyle="Solid" Font-Names="Copperplate Gothic Light" />
<asp:Button ID="CancelButton" runat="server" CommandName="Cancel"
Text="Cancel" BackColor="#577109" ForeColor="Black" BorderStyle="Solid" Font-Names="Copperplate Gothic Light" />
</td>
</tr>
</EditItemTemplate>
<EmptyDataTemplate>
<table runat="server" class="EDTtable" >
<tr>
<td>
No data was returned.</td>
</tr>
</table>
</EmptyDataTemplate>
<InsertItemTemplate>
<tr>
<td>
<asp:TextBox ID="NAMETextBox" runat="server" Text='<%# Bind("NAME") %>' />
</td>
<td>
</td>
<td>
<asp:TextBox ID="ADDRESSTextBox" runat="server" Text='<%# Bind("ADDRESS") %>' />
</td>
<td>
<asp:TextBox ID="GENDERTextBox" runat="server" Text='<%# Bind("GENDER") %>' />
</td>
<td>
<asp:TextBox ID="MOBILENOTextBox" runat="server" Text='<%# Bind("MOBILENO") %>' />
</td>
<td>
<asp:TextBox ID="PHOTOTextBox" runat="server" Text='<%# Bind("PHOTO") %>' />
</td>
<td>
<asp:CheckBox ID="BLOCKCheckBox" runat="server" Checked="false" Enabled="true" />
</td>
<td>
<asp:Button ID="InsertButton" runat="server" CommandName="Insert"
Text="Insert" BackColor="#577109" ForeColor="Black" BorderStyle="Solid" Font-Names="Copperplate Gothic Light"/>
<asp:Button ID="CancelButton1" runat="server" CommandName="Cancel"
Text="Clear" BackColor="#577109" ForeColor="Black" BorderStyle="Solid" Font-Names="Copperplate Gothic Light" />
</td>
</tr>
</InsertItemTemplate>
<ItemTemplate>
<tr class="ITtr">
<td>
<asp:Label ID="NAMELabel" runat="server" Text='<%# Eval("NAME") %>' />
</td>
<td>
<asp:Label ID="IDLabel" runat="server" Text='<%# Eval("ID") %>' />
</td>
<td>
<asp:Label ID="ADDRESSLabel" runat="server" Text='<%# Eval("ADDRESS") %>' />
</td>
<td>
<asp:Label ID="GENDERLabel" runat="server" Text='<%# Eval("GENDER") %>' />
</td>
<td>
<asp:Label ID="MOBILENOLabel" runat="server" Text='<%# Eval("MOBILENO") %>' />
</td>
<td>
<asp:Image ID="Image" runat="server" ImageUrl='<%#Eval("PHOTO") %>' Height="30" Width="30" />
</td>
<td>
<asp:CheckBox ID="BLOCKCheckBox" runat="server" Checked="false" Enabled="true" />
</td>
<td>
<asp:Button ID="DeleteButton1" runat="server" CommandName="Delete"
Text="Delete" BackColor="#577109" ForeColor="Black" BorderStyle="Solid" Font-Names="Copperplate Gothic Light" />
<asp:Button ID="EditButton1" runat="server" CommandName="Edit" Text="Edit" BackColor="#577109" ForeColor="Black" BorderStyle="Solid" Font-Names="Copperplate Gothic Light"/>
</td>
</tr>
</ItemTemplate>
<LayoutTemplate>
<table runat="server">
<tr runat="server">
<td runat="server">
<table ID="itemPlaceholderContainer" runat="server" border="1" class="LTtable" >
<tr runat="server" Class="LTtr">
<th runat="server">
NAME</th>
<th runat="server">
ID</th>
<th runat="server">
ADDRESS</th>
<th runat="server">
GENDER</th>
<th runat="server">
MOBILENO</th>
<th runat="server">
PHOTO</th>
<th runat="server">
BLOCK</th>
<th id="Th1" runat="server">
</th>
</tr>
<tr ID="itemPlaceholder" runat="server">
</tr>
</table>
</td>
</tr>
<tr runat="server">
<td runat="server" class="LTtd">
</td>
</tr>
</table>
</LayoutTemplate>
<SelectedItemTemplate>
<tr Class=".SITtr">
<td>
<asp:Label ID="NAMELabel" runat="server" Text='<%# Eval("NAME") %>' />
</td>
<td>
<asp:Label ID="IDLabel" runat="server" Text='<%# Eval("ID") %>' />
</td>
<td>
<asp:Label ID="ADDRESSLabel" runat="server" Text='<%# Eval("ADDRESS") %>' />
</td>
<td>
<asp:Label ID="GENDERLabel" runat="server" Text='<%# Eval("GENDER") %>' />
</td>
<td>
<asp:Label ID="MOBILENOLabel" runat="server" Text='<%# Eval("MOBILENO") %>' />
</td>
<td>
<asp:Label ID="PHOTOLabel" runat="server" Text='<%# Eval("PHOTO") %>' />
</td>
<td>
<asp:CheckBox ID="BLOCKCheckBox" runat="server" Checked="false" Enabled="true" />
</td>
<td>
<asp:Button ID="DeleteButton2" runat="server" CommandName="Delete"
Text="Delete" BackColor="#577109" ForeColor="Black" BorderStyle="Solid" Font-Names="Copperplate Gothic Light" />
<asp:Button ID="EditButton2" runat="server" CommandName="Edit" Text="Edit" BackColor="#577109" ForeColor="Black" BorderStyle="Solid" Font-Names="Copperplate Gothic Light"/>
</td>
</tr>
</SelectedItemTemplate>
</asp:ListView>
my aspx.cs coding is....
protected void ListView1_OnItemDataBound(object sender, ListViewItemEventArgs e) { if (e.Item.ItemType == ListViewItemType.DataItem) { CheckBox BLOCKCheckBox = (e.Item.FindControl("BLOCKCheckBox") as CheckBox); if (BLOCKCheckBox.Checked) {
}
else
{
}
}
}
Kindly help me.....
Thanks....
Aucun commentaire:
Enregistrer un commentaire