Need advice in setting column's width of a grid inside a repeater

G

Guest

Dear All:
Banckgroud: I have a datagrid which lives inside a repeater. Which is
working fine. What i need is to dyanamically set the column width of the
grid (which lieves inside the repeater). Is there any way, we accomplish
this? Any advice on this would be greatly appreciated.

Reza.

---BEGIN PART Of ListApp.aspx --->

<table>
<asp:Repeater ID="repL" DataSource='<%#
GetApplicationInfo(((RMS.Lib.DAO.Application)
Container.DataItem).ApplicationID)%>' runat="server">
<ItemTemplate>
<tr><td align="center"><%# ((RMS.Lib.DAO.Application)
Container.DataItem).Name %></td></tr>
<tr><td>

<asp:datagrid id="GridLS" DataSource='<%#
GetSGrid(((RMS.Lib.DAO.Application) Container.DataItem).ApplicationID) %>'
runat="server" ShowHeader="False" Width="100%" BorderColor="#ffffff"
EnableViewState="True"
autogeneratecolumns="false" HorizontalAlign="Center"
BorderStyle="None">
<alternatingitemstyle CssClass="datacell2"
HorizontalAlign="Center" Font-Size="smaller" />
<ItemStyle CssClass="datacell" HorizontalAlign="Center"
Font-Size="smaller" />
<Columns>
<asp:BoundColumn DataField="col1"></asp:BoundColumn>
<asp:BoundColumn DataField="col2"></asp:BoundColumn>
<asp:BoundColumn DataField="col3"></asp:BoundColumn>
</Columns>
</asp:datagrid>

</td>
</tr>
</ItemTemplate>
</asp:Repeater>
</table>
---END PART OF ListApp.aspx ----


---BEGIN PART OF CODE Behind ListApp.aspx.cs ----
protected DataTable GetSGrid(string id)
{

// BEGIN :: Trying to set the width of the column of the grid lives
inside the repeater
// folowing are the technique i was trying, but didn't work
// Question: is there any way we can set the width of the grid inside a
repeater?
int width1 = 5;
int width2 = 70;
int width3 = 25;
GridLS.Columns[0].ItemStyle.Width=new Unit(width1,UnitType.Percentage);
GridLS.Columns[1].ItemStyle.Width=new Unit(width2,UnitType.Percentage);
GridLS.Columns[2].ItemStyle.Width=new Unit(width3,UnitType.Percentage);
// END :: Trying to set the width of the column of the grid lives inside
the repeater

string sql = @"SELECT col1,col2,col3 FROM my_table where id="+id;
Summary s = new Summary();
DataSet ds = s.GetSiteList(sql);
DataTable gridSrouce = (DataTable) ds.Tables[0];

return gridSrouce;
}

---END PART OF CODE Behind ListApp.aspx.cs ----
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top