C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » DataGridView »

Retrieving value on click of checkbox in DataList C#


Posted Date: 24 Oct 2008    Resource Type: Code Snippets    Category: DataGridView
Author: TamannaMember Level: Silver    
Rating: 1 out of 5Points: 10



The following code-snippet described How to get the value of onClick of a CheckBox in DataList usingC#:
Motive :
To retrieve all ids, from Datalist 'DataList1' as in label 'Label1', wherever checkbox 'chkItem' is checked.


protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e)
{
foreach (Control var in DataList1.Controls)
{
CheckBox ch = (CheckBox)var.FindControl("chkItem");
if (ch != null)
{
if (ch.Checked)
{
Label lb = (Label)var.FindControl("Label1");
ListBox1.Items.Add(lb.Text);
}
}
}
}

Finally, write following lines of code in design of page:

<asp:DataList ID="DataList1" runat="server" OnItemCommand="DataList1_ItemCommand" Width="447px">
<ItemTemplate>
<table>
<tr>
<td>
<asp:CheckBox ID="chkItem" runat="server" /></td>
<td>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("CustomerID") %>'></asp:Label>
</td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>



Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Retrieving value  .  On click of checkbox  .  Of label  .  In DataList C#  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Jump to nth row or move up/down row on single click
Previous Resource: Datagrid - Editing, Updating, Cancel, Selecting Rows
Return to Discussion Resource Index
Post New Resource
Category: DataGridView


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use