Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem finding in witch row checkbox was fired

Status
Not open for further replies.

hlybbi

Programmer
Mar 19, 2003
91
IS
I hava a datalist with

<asp:CheckBox id="SecPage" AutoPostBack="True" OnCheckedChanged="Check_Clicked" runat="server"></asp:CheckBox>

the problem is i cant find out in whats row the checkbox was fired

Best regards Hlynur
 
Do you have a field that contains a primary key for the row?

--------------------------------------------------------------------------------------------------------------------------------------------

Need help finding an answer?

Try the search facility ( or read FAQ222-2244 on how to get better results.
 
OK in that case you should be able to use the ItemCreated method I think (I don't use DataLists much but I think you can!). Let me dig out an example URL...


--------------------------------------------------------------------------------------------------------------------------------------------

Need help finding an answer?

Try the search facility ( or read FAQ222-2244 on how to get better results.
 
Something like this:

<asp:CheckBox id="SecPage" AutoPostBack="True" OnCheckedChanged="Check_Clicked" runat="server" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "MyDataColumnName")%>'></asp:CheckBox>


public sub Check_Clicked(object sender, EventArgs e)
dim val as boolean= cbool(ctype(sender,checkbox).commandargment)

end sub


Keeping it Simple
 
this doesn´t work, or i am not understanding this.
what i am trying to to is this
i have a list of checkboxis and when someone checks one of them it should fire the Update_Command and i need to know witch was fired

public void Update_Command(Object sender, CommandEventArgs e) {
string sql = "UPDATE Users SET test=@tester WHERE ID=" + e.CommandArgument;

}

<asp:CheckBox id="SubItems" OnCommand="Update_Command" AutoPostBack="True" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "id")%>' runat="server">



Best regards Hlynur
 
In that case, then the above example is your best choice.
Using the edit,update commmand of a datalist, datagrid usually work a little different. First someone selects an edit button for an item. Then they type in a textbox or select a chechbox, and then they select an update or cancel button for that item in the list.
What you need to do is stick with the example above because what you want to do is custom and not the typical nature of the edit, update functions of a datalist.



<asp:DataList id="DataList1" runat=server >
<ItemTemplate>
<asp:CheckBox ID="Checkbox1" Runat=server Checked='<%# DataBinder.Eval(Container.DataItem, "Column1")%>'/>
</ItemTemplate>
</asp:DataList>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top