[Linq & VB] - Issue with custom gridview.http://forums.asp.net/t/1770993.aspx/1?+Linq+VB+Issue+with+custom+gridview+Tue, 21 Feb 2012 06:19:31 -050017709934838644http://forums.asp.net/p/1770993/4838644.aspx/1?+Linq+VB+Issue+with+custom+gridview+[Linq & VB] - Issue with custom gridview. <p>Hi,</p> <p>I have two problems with one of custom GridViews.</p> <p>Let's say that the database contains three tables:</p> <p>Student&nbsp; --&gt;&nbsp;&nbsp; StudentCourse&nbsp;&nbsp; &lt;-- &nbsp; Course</p> <p>Of course StudentCourse table contains Keys from two other tables</p> <p></p> <p>Now, on the website (which is an attendance list) I have created a Gridview:</p> <p style="padding-left:30px"><em>&lt;asp:GridView ID=&quot;grdAttendance&quot; runat=&quot;server&quot;&gt;</em></p> <p style="padding-left:30px"><em>&lt;/asp:GridView&gt;</em></p> <p></p> <p>and in VB filled it with data:</p> <p style="padding-left:30px"><em>Dim AttList = From myList In myDB.PersonCourses _</em><br> <em>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Where myList.CourseId = (Request.QueryString(&quot;CourseID&quot;)) _</em><br> <em>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Select New With { _</em><br> <em>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; myList.Person.FirstName, _</em><br> <em>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; myList.Person.LastName _</em><br> <em>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</em><br> <br> <em>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; grdAttendance.DataSource = AttList</em><br> <em>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; grdAttendance.DataBind()</em></p> <p></p> <p>Now, two simple questions:</p> <p>1. I want to use aliases in the headers of that table to make it look better (&quot;First Name&quot; as myList.Person.FirstName etc.). All articles I found were describing how to do it in C# :(</p> <p>2. I want to add additional template column: &quot;signature&quot;. When I do it like this:</p> <p><em>&nbsp;&nbsp;&nbsp; &lt;asp:GridView ID=&quot;grdAttendance&quot; runat=&quot;server&quot;&gt;</em><br> <em>&nbsp;&nbsp;&nbsp; &lt;Columns&gt;</em><br> <em>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;asp:TemplateField HeaderText=&quot;Signature&quot;&gt;</em><br> <em>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;ItemTemplate&gt;</em><br> <em>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;asp:TextBox ID=&quot;TextBox1&quot; runat=&quot;server&quot;&gt;&lt;/asp:TextBox&gt;</em><br> <em>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/ItemTemplate&gt;</em><br> <em>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/asp:TemplateField&gt;</em><br> <em>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/Columns&gt;</em><br> <em>&nbsp;&nbsp;&nbsp; &lt;/asp:GridView&gt;</em></p> <p></p> <p>it adds new column left from columns created with the SQL query.&nbsp; Is there any way I could move it to the right?</p> <p></p> <p>Thanks for any suggestions.</p> 2012-02-18T09:40:59-05:004839062http://forums.asp.net/p/1770993/4839062.aspx/1?Re+Linq+VB+Issue+with+custom+gridview+Re: [Linq & VB] - Issue with custom gridview. <p>up?</p> 2012-02-18T19:58:33-05:004840022http://forums.asp.net/p/1770993/4840022.aspx/1?Re+Linq+VB+Issue+with+custom+gridview+Re: [Linq & VB] - Issue with custom gridview. <p>Hello</p> <p></p> <blockquote><span class="icon-blockquote"></span> <h4>gadujr</h4> 1. I want to use aliases in the headers of that table to make it look better (&quot;First Name&quot; as myList.Person.FirstName etc.). All articles I found were describing how to do it in C# :(</blockquote> <p></p> <p>Plese use anoymous class filename and properties</p> <p><em>Dim AttList = From myList In myDB.PersonCourses _</em><br> <em>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Where myList.CourseId = (Request.QueryString(&quot;CourseID&quot;)) _</em><br> <em>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Select New With { _</em><br> <em>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="text-decoration:underline">.<strong>FirstName</strong></span> = myList.Person.FirstName, _</em><br> <em>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="text-decoration:underline">.<strong>LastName</strong></span> = myList.Person.LastName _</em><br> <em>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</em><br> <br> <em>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; grdAttendance.DataSource = AttList</em><br> <em>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; grdAttendance.DataBind()</em></p> <p><em></p> <blockquote><span class="icon-blockquote"></span> <h4>gadujr</h4> it adds new column left from columns created with the SQL query.&nbsp; Is there any way I could move it to the right?</blockquote> </em> <p></p> <p>You have to cancel AutoGenerated columns by setting it to falseand then dynamically add columns one by onein the Edit ColumnsWizard windowyou can adjust the order of these columns</p> <p>Reguards</p> 2012-02-20T00:34:31-05:004841031http://forums.asp.net/p/1770993/4841031.aspx/1?Re+Linq+VB+Issue+with+custom+gridview+Re: [Linq & VB] - Issue with custom gridview. <p>Thanks a million for that. Strange is that I've been trying that previously and it didn't work but worked now - mirracle :)</p> <p></p> <p>One more question about canceling the &quot;AutoGenerated&quot; option. After disabling it I lost several columns I generate with the SQL query. Could you help me with adding them back again?</p> <p></p> <p>Thanks</p> <p>K.</p> <p></p> 2012-02-20T11:14:49-05:004842295http://forums.asp.net/p/1770993/4842295.aspx/1?Re+Linq+VB+Issue+with+custom+gridview+Re: [Linq & VB] - Issue with custom gridview. <p></p> <blockquote><span class="icon-blockquote"></span> <h4>gadujr</h4> One more question about canceling the &quot;AutoGenerated&quot; option. After disabling it I lost several columns I generate with the SQL query. Could you help me with adding them back again?</blockquote> <p></p> <p>Please re-generate themand you can only put the column names you want in the select statement</p> 2012-02-21T06:19:31-05:00