By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,361 Members | 1,700 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,361 IT Pros & Developers. It's quick & easy.

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

P: n/a
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.


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

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

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

---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
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 ----
Nov 19 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.