Web Parts, gridviews, bind and eval

Last post 08-20-2007 5:32 AM by humble-apprentice. 4 replies.

Sort Posts:

  • Web Parts, gridviews, bind and eval

    08-02-2007, 2:46 AM

    Hi all,

     This is the situation: I have a web part that has a GridView and I would like the GridView in the Web Part to have the same behaviour as the GridView shown under "Formatted GridView Editing" in http://msconline.maconstate.edu/Tutorials/ASPNET2/ASPNET09/aspnet09-01.aspx. The problem is that, as far us I understand, I can't create a web part by using tags, like the code shown, I would have to use classes and instances of them. Now, everything is easy until you get to <%# Bind() %> and <%# Eval() %>, how can I represent them? Would I have to write my own?

     Here is a sample of the code and the tags I want to translate:

     <asp:TemplateField HeaderText="Type"
        ItemStyle-VerticalAlign="Top">
        <ItemTemplate>
          <asp:Label Text='<%# Eval("ItemType") %>' Runat="Server"/>
        </ItemTemplate>
        <EditItemTemplate>
          <asp:DropDownList id="EditType" DataSourceID="TypeSource" Runat="Server"
            DataTextField="ItemType" DataValueField="ItemType" SelectedValue='<%# Bind("ItemType") %>'/>
        </EditItemTemplate>
      </asp:TemplateField>

    The underlined lines are what I don't know how to translate.

     Thank you!

    Thanks,

    humble-apprentice
    Filed under: , , ,
  • Re: Web Parts, gridviews, bind and eval

    08-06-2007, 2:03 AM

    Hi,

    Please don't create your GridView in WebPart Zones directly. You may use Web User Control to handle that. Just create a Web User Control to wrap your gridview and bind it with your database. And back to webpart page, just register the user control and declare it in your WebPart zones.

    Thanks.

    Sincerely,
    Michael Jin.
    Microsoft Online Community Support

  • Re: Web Parts, gridviews, bind and eval

    08-08-2007, 2:32 AM

    Hi Nai-Dong Jin,

    That will be fine if I was using the Portal Framework but I am using Sharepoint 2007. Unless you know a way to package it so that I can put it in Sharepoint then I guess I am stuck with this way. Also, I need to change the Select statement depending on the user's input and there are parameters that have to be passed from a connected web part.

     Looking forward to your reply,

     

    Thanks,

    humble-apprentice
  • Re: Web Parts, gridviews, bind and eval

    08-08-2007, 5:51 AM
    Answer

    Hi,

    Why can't we use user controls in SharePoint WebParts? You can achieve it by using the dynamically compiled assembly. In terms of the parameters, you may expose some public properties in your user control, and visit these properties in WebPart page. See the following link,

    http://weblogs.asp.net/jan/archive/2004/04/04/107398.aspx

    Thanks.

    Sincerely,
    Michael Jin.
    Microsoft Online Community Support

  • Re: Web Parts, gridviews, bind and eval

    08-20-2007, 5:32 AM

    Hi Nai-Dong,

     I couldn't use it because I had to make some runtime changes. I came accross different code on the web and with bits and pieces from there I was able to generate my control (as soon as I finish it I will post a small tutorial for those who might need it). Now there is another "interesting" and "fun" problem. The control has to create a popup window showing a file that comes from my database. I am able to store the file on the executing page (see post http://forums.asp.net/t/1077555.aspx) but I am unable to browser. Do you, or does anybody, know where to store a file so that it is browsable? I am using Sharepoint 2007.

    Thanks,

    humble-apprentice
Page 1 of 1 (5 items)
Microsoft Communities
Page view counter