T
tfsmag
I tried getting the record count by doing it through the ItemDataBound
on the repeater with no luck... Can someone help me out here? Thanks in
advance.
Here is the code that sets up the data relation (it works fine)
------------------------------------------------
private void getlinks()
{
string connectionInfo =
ConfigurationSettings.AppSettings["ConnectionString"];
using(SqlConnection connection = new SqlConnection(connectionInfo))
{
connection.Open();
SqlDataAdapter da = new SqlDataAdapter("EXECUTE
sp_getlinkcat",connection);
DataSet ds = new DataSet();
da.Fill(ds,"link_cat");
SqlDataAdapter da2 = new SqlDataAdapter("EXECUTE sp_getlinks"
,connection);
da2.Fill(ds,"links");
DataRelation drel;
drel = new
DataRelation("myrelation",ds.Tables["link_cat"].Columns["cat_id"],ds.Tables["links"].Columns["cat_id"]);
ds.Relations.Add(drel);
//thecount.Text=ds.Tables["links"].ChildRelations.Count.ToString();
displaycat.DataSource = ds.Tables["link_cat"];
displaycat.DataBind();
}
}
------------------------------------------
Here is the item databound I tried to generate the count
------------------------------------------
void displaycat_ItemDataBound(Object Sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType==ListItemType.Item)
{
DataRow[] drows = getthelinks.DataSource as DataRow[];
int count=0;
foreach (DataRow dr in drows)
{
count ++;
}
Literal thecount = e.Item.Controls[2] as Literal;
thecount.Text=count.ToString();
}
}
-----------------------------------------
Thanks!
Jeff
on the repeater with no luck... Can someone help me out here? Thanks in
advance.
Here is the code that sets up the data relation (it works fine)
------------------------------------------------
private void getlinks()
{
string connectionInfo =
ConfigurationSettings.AppSettings["ConnectionString"];
using(SqlConnection connection = new SqlConnection(connectionInfo))
{
connection.Open();
SqlDataAdapter da = new SqlDataAdapter("EXECUTE
sp_getlinkcat",connection);
DataSet ds = new DataSet();
da.Fill(ds,"link_cat");
SqlDataAdapter da2 = new SqlDataAdapter("EXECUTE sp_getlinks"
,connection);
da2.Fill(ds,"links");
DataRelation drel;
drel = new
DataRelation("myrelation",ds.Tables["link_cat"].Columns["cat_id"],ds.Tables["links"].Columns["cat_id"]);
ds.Relations.Add(drel);
//thecount.Text=ds.Tables["links"].ChildRelations.Count.ToString();
displaycat.DataSource = ds.Tables["link_cat"];
displaycat.DataBind();
}
}
------------------------------------------
Here is the item databound I tried to generate the count
------------------------------------------
void displaycat_ItemDataBound(Object Sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType==ListItemType.Item)
{
DataRow[] drows = getthelinks.DataSource as DataRow[];
int count=0;
foreach (DataRow dr in drows)
{
count ++;
}
Literal thecount = e.Item.Controls[2] as Literal;
thecount.Text=count.ToString();
}
}
-----------------------------------------
Thanks!
Jeff