I have the following itemTemplate in my datalist
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" CommandName="Select" autopostback="True" runat="server">'<%# Eval("ThreadTitle") %>'</asp:LinkButton>
</ItemTemplate>
This is my dataList mark up:
<asp:DataList ID="DataList1" runat="server"
DataSourceID="AllQuestionAskedDataSource"
GridLines="Horizontal" DataKeyField="ThreadsID" >
This is the sqldatasource:
<asp:SqlDataSource ID="AllQuestionAskedDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:CP_AllQuestionsAnswered %>" SelectCommand="SELECT ThreadTitle, ThreadsID
FROM Threads
WHERE UsersID=@UserID" onselecting="AllQuestionAskedDataSource_Selecting">
I am trying to use one of the following events handlers:
protected void DataList2_SelectedIndexChanged(object sender, EventArgs e)
{
}
protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e)
{
}
What I want to obtain in one of those event handlers the ThreadID associated with the row selected (by clicking on the row in the datalist) and get the ThreadTitle parameter from the specific row selected..
How can I achieve that task?
I basically want to retrieve the sql parameters that i feed into the sqldatasource, relating to the specific row clicked!!
Solved it myself:
protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e)
{
LinkButton link = (LinkButton)e.Item.FindControl("LinkButton1");
string threadTitle = link.Text;
string recordID = (DataList1.DataKeys[e.Item.ItemIndex]).ToString();
string special = "";
}
enter code here
You can do like..