Results 1 to 16 of 16

Thread: [RESOLVED] Dynamic columns width

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Aug 2010
    Location
    Sunshine
    Posts
    25

    Resolved [RESOLVED] Dynamic columns width

    Hi,

    I'm using dynamic columns boundfield and templatefield in gridview, the GV embeded in a panel (autoscroll:auto;width:fixe), I fixed 3 columns to fit the panel's width , when I add exceed the 3 columns the width changes !

  2. #2
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Dynamic columns width

    Hey,

    Can you show the markup that you are using?

    Gary

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Aug 2010
    Location
    Sunshine
    Posts
    25

    Re: Dynamic columns width

    I need to recreate columns and rebind the gridview when I modify items .

    // create Left Box columns
    this.leftBox.AutoGenerateColumns = false;
    this.leftBox.Columns.Clear();
    TemplateField tf = new TemplateField();
    this.leftBox.Columns.Add(tf);
    tf.ItemTemplate = new CheckBoxTemplateHandler();
    tf.ItemStyle.Height = 30;
    tf.ItemStyle.Width = 30;

    for (int x = 1; x <= this.LeftBoxColumns; x++)
    {
    if (x <= this.LeftBoxColumns)
    {
    BoundField nameColumn = new BoundField();
    nameColumn.DataField = x.ToString();
    if (x == 1)
    {

    nameColumn.ItemStyle.Width = 70;
    nameColumn.ItemStyle.Height = 30;
    }
    else
    {

    nameColumn.ItemStyle.Width = 220;
    nameColumn.ItemStyle.Height = 30;
    }
    this.leftBox.Columns.Add(nameColumn);
    }
    }
    // bind Data


    this.leftBox.DataSource = DTSourceBox;
    this.leftBox.DataBind();

  4. #4
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Dynamic columns width

    That is the server side code, I was asking about the ASPX markup, i.e. your panel, and it's surrounding elements.

    Gary

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Aug 2010
    Location
    Sunshine
    Posts
    25

    Re: Dynamic columns width

    I'm working with Custom Server control , for the panel and it's surrounding elements see the code below :

    this._leftBoxContainer.ID = "LeftBoxContainer";
    this._leftBoxContainer.Height =(this.LeftBoxRows*30)+20;
    this._leftBoxContainer.Width = 320;
    this._leftBoxContainer.ScrollBars = ScrollBars.Auto;
    this._leftBoxContainer.BorderWidth = 2;
    this._leftBoxContainer.GroupingText = "UnBound";
    this was in initialization .

  6. #6
    Frenzied Member
    Join Date
    Mar 2004
    Location
    Orlando, FL
    Posts
    1,618

    Re: Dynamic columns width

    That's still server side code, he's looking for the markup (the HTML looking page).
    Sean

    Some days when I think about the next 30 years or so of my life I am going to spend writing code, I happily contemplate stepping off a curb in front of a fast moving bus.

  7. #7
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Dynamic columns width

    Are you saying that you are dynamically generating all the controls on the page? Is there nothing in the ASPX markup?

    Gary

  8. #8

    Thread Starter
    Junior Member
    Join Date
    Aug 2010
    Location
    Sunshine
    Posts
    25

    Re: Dynamic columns width

    Mrs ,

    do you mean ASPx Markup at runtime ! I work on a custom server control that contains gridview with dynamic columns .

  9. #9
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Dynamic columns width

    Hold on.

    So you are doing a "true" Server Control, not a composite one. So you are handling all the control generation in the server side code. Correct?

    If so, is it possible for you to show all the code that you are using?

    Gary

  10. #10

    Thread Starter
    Junior Member
    Join Date
    Aug 2010
    Location
    Sunshine
    Posts
    25

    Re: Dynamic columns width

    I think that I gave you the necessary , I hope find someone met the same problem .

    Thank you.

  11. #11
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Dynamic columns width

    Well not really no.

    You have provided some sample code, yes, however, there are so many other things that could be causing the problem that you are having, so without directly running the code that you are using, it will be difficult to replicate on my machine.

    I am not expecting you to upload all your code, but rather a sample of it. i.e. one complete webpage, that is rendering your control, so that I can see the problem that you are having, and make suggestions.

    Gary

  12. #12

    Thread Starter
    Junior Member
    Join Date
    Aug 2010
    Location
    Sunshine
    Posts
    25

    Re: Dynamic columns width

    sorry I'm late,

    the Markup in short is :
    <td style:"Height:30px;Width:200px"> Text <td/>
    the GridView is embedded in a Panel(style fixed).
    I hope that Css can help.
    Any suggestions ?

  13. #13
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Dynamic columns width

    souloff,

    Why are you so hesitant in showing us complete sections of code?

    What you have provided isn't enough for anyone to try and help you. We would need a complete sample of the ASPX that you are using to include your server control, as well as all the code used to render your control.

    That way, we can take it, and try and reproduce the problem on our systems, and then make suggestions as to how to proceed.

    Gary

  14. #14

    Thread Starter
    Junior Member
    Join Date
    Aug 2010
    Location
    Sunshine
    Posts
    25

    Re: Dynamic columns width

    I would to simplify things,

    Code :

    <table id="Control">
    <tr>
    <td align="center"><div id="Control" style="border-width:2px;border-style:solid;height:200px;width:320px;overflow:auto;">
    <div>
    <table cellspacing="0" rules="all" border="1" id="Control" style="color:Black;background-color:White;border-collapse:collapse;">
    <tr>
    <td style="height:30px;width:30px;"><input id="Control_ctl13_cbselect" type="checkbox" name="Control13$cbselect" onclick="javascript:setTimeout('__doPostBack(\'Control13$cbselect\',\'\')', 0)" /></td><td style="height:30px;width:70px;">A102</td><td style="height:30px;width:220px;">ppppppppppppp</td><td>3</td><td>hhhhhhhhhhhhh</td>
    </tr><tr>
    <td style="height:30px;width:30px;"><input id="Control_ctl14_cbselect" type="checkbox" name="Control14$cbselect" onclick="javascript:setTimeout('__doPostBack(\'Control14$cbselect\',\'\')', 0)" /></td><td style="height:30px;width:70px;">A200</td><td style="height:30px;width:220px;">kkkkkkkkkkkkk</td><td>20</td><td>hhhhhhhhhhhh</td>
    </tr><tr>
    <td style="height:30px;width:30px;"><input id="Control_ctl15_cbselect" type="checkbox" name="Control15$cbselect" onclick="javascript:setTimeout('__doPostBack(\'Control15$cbselect\',\'\')', 0)" /></td><td style="height:30px;width:70px;">A201</td><td style="height:30px;width:220px;">yyyyyyyyyyyyyyyy</td><td>15</td><td>Ihhhhhhhhhhhh</td>
    </tr><tr>
    <td style="height:30px;width:30px;"><input id="Control_ctl16_cbselect" type="checkbox" name="Control16$cbselect" onclick="javascript:setTimeout('__doPostBack(\'Control16$cbselect\',\'\')', 0)" /></td><td style="height:30px;width:70px;">A202</td><td style="height:30px;width:220px;">yyyyyyyyyyyyyy</td><td>12</td><td>Ihhhhhhhh</td>
    </tr><tr>
    <td style="height:30px;width:30px;"><input id="Control_ctl17_cbselect" type="checkbox" name="Control17$cbselect" onclick="javascript:setTimeout('__doPostBack(\'Control17$cbselect\',\'\')', 0)" /></td><td style="height:30px;width:70px;">A203</td><td style="height:30px;width:220px;">tttttttttttttttttttttttt</td><td>12</td><td>hhhhhhhhh</td>
    </tr><tr>
    <td style="height:30px;width:30px;"><input id="Control_ctl18_cbselect" type="checkbox" name="Control18$cbselect" onclick="javascript:setTimeout('__doPostBack(\'Control18$cbselect\',\'\')', 0)" /></td><td style="height:30px;width:70px;">A204</td><td style="height:30px;width:220px;">rrrrrrrrrrrrrr</td><td>13</td><td>Ihhhhhhh</td>
    </tr><tr>
    <td style="height:30px;width:30px;"><input id="Control_ctl19_cbselect" type="checkbox" name="Control19$cbselect" onclick="javascript:setTimeout('__doPostBack(\'Control19$cbselect\',\'\')', 0)" /></td><td style="height:30px;width:70px;">Vol-001</td><td style="height:30px;width:220px;">qqqqqqqqqqqqqqqqqqqtd><td>10</td><td>hhhhhhhhhh</td>
    </tr><tr>
    <td style="height:30px;width:30px;"><input id="Control_ctl20_cbselect" type="checkbox" name="Control20$cbselect" onclick="javascript:setTimeout('__doPostBack(\'Control20$cbselect\',\'\')', 0)" /></td><td style="height:30px;width:70px;">AR06TB</td><td style="height:30px;width:220px;">xxxxxxxxxxxxx</td><td>8</td><td>hhhhhhhhhh</td>
    </tr>
    </table>

  15. #15

    Thread Starter
    Junior Member
    Join Date
    Aug 2010
    Location
    Sunshine
    Posts
    25

    Re: Dynamic columns width

    solved by defining gridviews width.

  16. #16
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Dynamic columns width

    If your question has been answered, can you remember to go back and mark your thread as resolved?

    Gary

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width