Hello again... I tried doing that in many ways... always something was wrong.
So, I have a RadGrid for my products from database. 1 product per row - ok.
Now for each product I have at least 1 image in other table. That's why I wanted to add RadRotator in one column so that for each product people can see all images (RadRotator with buttons).
Here's the code for the column with photos:
Photos size are different (some 212 x 212, 211 x 211 - small differences) so I want them to fit.
Also I added a server-side code:
so it checks the amount of photos for current row. If it's > 1 then add buttons to rotator, else set it to AutomaticAdvance as it won't advance when there'll be 1 photo.
currently that column looks like in the attached file.
Problems:
1. When I have many photos and buttons in RadRotator - it's centered, when I set it to AutomaticAdvance it on the left side, why?
2. As You can see in first 3 rows, there are more than 1 photo per row. But instead of showing only one photo with ability to rotate, I see one photo and a part of second photo, when I rotate then, I see part of second photo and part of 3rd photo etc... I think I messed something with the sizes as I'd like to see max 1 photo.
Best Regards
Darek
So, I have a RadGrid for my products from database. 1 product per row - ok.
Now for each product I have at least 1 image in other table. That's why I wanted to add RadRotator in one column so that for each product people can see all images (RadRotator with buttons).
Here's the code for the column with photos:
<
telerik:GridTemplateColumn
HeaderText
=
"Zdjęcia"
HeaderStyle-Width
=
"120px"
HeaderStyle-HorizontalAlign
=
"Center"
ItemStyle-HorizontalAlign
=
"Center"
AllowFiltering
=
"false">
<
ItemTemplate
>
<
telerik:RadRotator
runat
=
"server"
ID
=
"itemsRotator"
OnDataBinding
=
"RadRotator_OnDataBinding"
Height
=
"128px"
>
<
ItemTemplate
>
<
telerik:RadBinaryImage
runat
=
"server"
ID
=
"RadBinaryImage1"
DataValue='<%#Eval("zdjecie") %>'
AutoAdjustImageControlSize="false" Width="128px" Height="128px" ResizeMode="Fit" ImageAlign="Middle"/>
</
ItemTemplate
>
</
telerik:RadRotator
>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
Photos size are different (some 212 x 212, 211 x 211 - small differences) so I want them to fit.
Also I added a server-side code:
protected
void
RadRotator_OnDataBinding(
object
sender, EventArgs e)
{
string
tmp = obecnyitem[
"ProductID"
].Text;
RadRotator radrotator = (RadRotator)obecnyitem.FindControl(
"itemsRotator"
);
SqlConnection sqlconn =
new
SqlConnection();
sqlconn.ConnectionString = @
"data source=UNDERGROUND\SQLEXPRESS;UID=sa;PWD=ds3236y;initial catalog=Products"
;
sqlconn.Open();
SqlCommand cmd =
new
SqlCommand();
cmd.Connection = sqlconn;
cmd.CommandText =
"select count(1) from katalog_zdjecia where indeks = '"
+ tmp +
"'"
;
int
tmp1 = System.Convert.ToInt32(cmd.ExecuteScalar());
sqlconn.Close();
cmd.Dispose();
sqlconn.Dispose();
SqlDataSource sqldatsrc =
new
SqlDataSource();
sqldatsrc.ConnectionString = @
"data source=UNDERGROUND\SQLEXPRESS;UID=sa;PWD=ds3236y;initial catalog=Products"
;
sqldatsrc.ProviderName =
"System.Data.SqlClient"
;
sqldatsrc.SelectCommand =
"select indeks, zdjecie from katalog_zdjecia where indeks = '"
+ tmp +
"'"
;
radrotator.DataSource = sqldatsrc;
if
(tmp1 > 1)
radrotator.RotatorType = RotatorType.Buttons;
else
radrotator.RotatorType = RotatorType.AutomaticAdvance;
}
so it checks the amount of photos for current row. If it's > 1 then add buttons to rotator, else set it to AutomaticAdvance as it won't advance when there'll be 1 photo.
currently that column looks like in the attached file.
Problems:
1. When I have many photos and buttons in RadRotator - it's centered, when I set it to AutomaticAdvance it on the left side, why?
2. As You can see in first 3 rows, there are more than 1 photo per row. But instead of showing only one photo with ability to rotate, I see one photo and a part of second photo, when I rotate then, I see part of second photo and part of 3rd photo etc... I think I messed something with the sizes as I'd like to see max 1 photo.
Best Regards
Darek