Re: WebPart Postback
- From: "Sujath" <sujath@xxxxxxxxx>
- Date: 28 Sep 2006 02:23:02 -0700
I understand that you need a dropdown that has the Room nos in it and
if you select a particular room and Press button show events then the
datagrid should be populated with all the fields or events
What I suggest is in the CreateChildControl function make use of the
Dropdown_Load event to populate the dropdown from the existing list
protected override void CreateChildControls()
{
EnsureChildControls();
RolesList = new DropDownList();
RolesList.Load += new EventHandler(RolesList_Load);
Controls.Add(RolesList);
}
In the Load event populate the Dataset and put the dataset in a Session
so that you can retrieve it, Also make sure that your web.config files
has session enabled in it
Create a new button event handler, populate the datagrid from the
dataset
Hope this will be helpful
Also I hope there is filter option in Sharepoint which will satisfy you
requirement
One more thing I can suggest is that you can make use of Form Webpart
where you will have to give connections for the webpart
modifying the Source Editor is also possible
The default code will be
<div onkeydown="javascript:if (event.keyCode == 13) _SFSUBMIT_"><input
type="text" name="T1"/><input type="button" value="Go"
onclick="javascript:_SFSUBMIT_"/></div>
You can modify the textbox to be dropdown and populate it from the
existing list
Make uso your custom _SFSUBMIT_ function to populate the datagrid
..Net Frenzy wrote:
Hi Sujath,
Thanks for the reply. Well, I got your idea and implemented it and
working on it. However, I would like you to have a look at the right
scenario of what i am doing so you will be able to help me a lot
better.
There is a Sharepoint List that contains a list of events that are
being held currently. This includes Event Title, Location, Event Start,
Event Begin which has information like
TEST meeting, Room 1, 12:00, 14:00
Stress ABC, Room 2, 13:30, 14:00
Now, I am databinding a dropdownlist to get the list of only rooms from
the above mentioned list. Like this:
First I declared a myDDList in CreateChildControls and in renderwebpart
I render the control, have a look.
Protected Overrides Sub RenderWebPart(ByVal output As
System.Web.UI.HtmlTextWriter)
myDDList.RenderControl(output)
End Sub ' < - ENd of Render web part
Now this is what i am doing at the moment. I am calling OnLoad
seprately. Here, I open the Sharepoint List and then the List's view
and pass it to a dataset. Then the dataset is used as datasource for
dropdownlist databinding. But out of this dataset I know for example
ABC is datatextfield, well, you know for proper databinding.
Protected Overrides Sub OnLoad(ByVal e As System.EventArgs)
Dim oSite As SPSite
Dim oWeb As SPWeb
oSite = New SPSite("http://")
oWeb = oSite.OpenWeb
Dim sList As SPList
sList = oWeb.Lists("Events") '<-- List in Sharepoint
Dim oCol As SPListItemCollection
Dim query As SPQuery
query = New SPQuery(sList.Views("All Items")) ' <-- View of
the list
oCol = sList.GetItems(query)
Dim Rooms As New DataSet
Rooms.Tables.Add(oCol.GetDataTable) '< -- Dataset gets
populated
If Page.IsPostBack Then
myDDList.DataSource = dsRooms.Tables(0)
myDDList.DataTextField = "ABC"
myDDList.DataValueField = "XYZ"
drpRoom.DataBind()
End If
End Sub
This way does not work.
Also, Sujath I want to tell you that I dont want that datagrid to be
populated on dropdownlist selection changed infact I have a button
which will produce the datagrid.
So the actions are
1. Select Room
2. Press button 'Show Events'
3. DataGrid Produced
I am sorry if this will be a problem for you but your suggestions will
be immensly helpful to me. Where is the proper way to write a postback
here ??
Thanks
.
- References:
- WebPart Postback
- From: .Net Frenzy
- Re: WebPart Postback
- From: Sujath
- Re: WebPart Postback
- From: .Net Frenzy
- Re: WebPart Postback
- From: Sujath
- Re: WebPart Postback
- From: .Net Frenzy
- WebPart Postback
- Prev by Date: Programmatically updating custom attribute
- Next by Date: Delete Users Programmatically
- Previous by thread: Re: WebPart Postback
- Next by thread: "Manage Profile Database" An error has occurred while accessing SQL database
- Index(es):