It is a Windows Form Application in C#.
I am using DataRepeater
Control in which I am displaying three columns:
Text Label
,Link Label
,Link Label
Following is the screenshot:
Following is the code which populates DataRepeater
:
private void Get_StaffLogins_RequestList()
{
mySqlConnection = DBAccess.getConnection();
mySqlConnection.Open();
DataTable dt = sysadmin.getStaffLoginsRequests(mySqlConnection);
BindingSource bSource = new BindingSource();
staff_id.DataBindings.Add("Text", bSource, "staff_id");
//accessLink.DataBindings.Add("Value", bSource, "staff_id");
//denyLink.DataBindings.Add("Value", bSource, "staff_id");
if (dt.Rows.Count > 0)
{
bSource.DataSource = dt;
r_msgs.DataSource = bSource;
}
else
{
r_msgs.DataSource = String.Empty;
notify.Text = "There are no Pending requests for staff logins!";
}
mySqlConnection.Close();
}
private void accessLink_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
//Access Link Clicked
}
private void denyLink_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
//Deny Link Clicked
}
Now what I need is that when User clicks on Access
or Deny
Link I somehow get corresponding StaffID so that I can mark that particular staffID Access/Denied in Database.
How can I attribute each Row Link Labels with unique staff ids?
thanks in advance!
I resolved this issue by getting Current Item Index of DataRepeater:
private void accessLink_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
//Access Link Clicked
int RequestNumber = r_msgs.CurrentItemIndex;
MessageBox.Show(RequestNumber.toString()+1);
//Remaining Code
}
This code Prints the Row number of the Access Link Label, and that's what I wanted!