Hi all!
I've a Web User Control with 4 Link Buttons, that will be a custumized menu interface. This way the user can have 0,1,2,3 or 4 all present Menu shorcuts (the way this is made is not the issue here).
My problem is that i must know how many menus he have select, and show then in each link button. I think i'm close to it, but no text is show in each button... Can anyone help me. I'am using SQL7. Tks in advance.
I've a Web User Control with 4 Link Buttons, that will be a custumized menu interface. This way the user can have 0,1,2,3 or 4 all present Menu shorcuts (the way this is made is not the issue here).
My problem is that i must know how many menus he have select, and show then in each link button. I think i'm close to it, but no text is show in each button... Can anyone help me. I'am using SQL7. Tks in advance.
Code:
private void Pop_Atalhos()
{
hypPref1.Text="< Empty Slot >";
hypPref2.Text="< Empty Slot >";
hypPref3.Text="< Empty Slot >";
hypPref4.Text="< Empty Slot >";
SqlConnection conn= new SqlConnection (Application["SQLString"].ToString());
SqlDataReader dr;
try
{
SqlCommand cmd = new SqlCommand ();
cmd.CommandTimeout= 60;
cmd.Connection= conn;
cmd.CommandType=CommandType.Text;
cmd.CommandText="SELECT Count(*) FROM TAB_Acessos WHERE " +
"Utilizador='" + Application["UserLog"].ToString() +
"' and Personalizacao='Y'";
conn.Open();
if (conn.State==ConnectionState.Open)
{
object objCount = cmd.ExecuteScalar();
int iCount = (int) objCount;
cmd.CommandText="Select (Menu + ' - ' + Sub) as Hyp " +
"from TAB_Acessos where Utilizador='" +
Application["UserLog"].ToString()+ "' and " +
"Personalizacao='Y' order by Menu,Sub";
dr=cmd.ExecuteReader();
while (dr.Read())
if (iCount>0)
{
hypPref1.Text =dr.GetSqlString(1).ToString();
if (iCount>1)
{
dr.NextResult();
hypPref2.Text=dr.GetSqlString(1).ToString();
if (iCount>2)
{
dr.NextResult();
hypPref3.Text=dr.GetSqlString(1).ToString();
if (iCount>3)
{
dr.NextResult();
hypPref4.Text=dr.GetSqlString(1).ToString();
}
}
}
}
}
}
catch
{
}
finally
{
conn.Close();
}
}