-
November 3rd, 2006, 06:13 AM
#1
Datagrid with DropdownMenu and Button
hi
i hv a Datagrid which hv a dropdownmenu and a button in each row
i want to populate the dropdown menu inside the Datagrid..
i want to add Upload button inside the datagrid..
any idea pls
waiting for ur valuable reply
veeresh
-
November 3rd, 2006, 08:50 AM
#2
Re: Datagrid with DropdownMenu and Button
Add TemplateField into GridView(I forget the name in DataGrid), and then add whatever control as you want into ItemTemplete.
-
November 3rd, 2006, 09:24 AM
#3
Re: Datagrid with DropdownMenu and Button
Yes
or to go more in detail :
<datagrid....
<asp:TemplateColumn HeaderText="company">
<ItemTemplate>
<aspropDownList ID="ddlcompany" runat="server" DataValueField="companycode" DataTextField="companyname"
DataSource='<%# GetACompany() %>'> </aspropDownList>
</ItemTemplate>
</asp:TemplateColumn>
... same itemtemplate voor button ..
<asp:button id="cmdUpload" command="Upload" runat="server">....
...
</datagrid>
then in your codebehind build a dataset in the function getcompany en return it.
Function Getcompany() As Data.DataSet
Try
Dim dscompany As New Data.DataSet
.... get data from database and fill dataset
Return dscomlpany
Catch ex As Exception
Return Nothing
End Try
End Function
that should work for you...
greetz
Geert
-
November 4th, 2006, 12:08 AM
#4
Re: Datagrid with DropdownMenu and Button
hi
thankyou.. i hv populated dropdown list..
now i want to add a button to the datagrid..
here is the code. i hv used ..
<asp:TemplateColumn HeaderText="File Name">
<ItemStyle Wrap="False" />
<HeaderStyle CssClass="orderIdItem" Wrap="False" />
<ItemTemplate>
<asp:ImageButton ID=Upload runat=server />
</ItemTemplate >
</asp:TemplateColumn>
In the Code Behind..
ImageButton
img = (ImageButton)item.Cells[2].Controls[1];
//ImageButton img = new ImageButton();
uploadurl =
"~/Skins/" + skinname + "/Uploadnormal.gif";
img.ImageUrl=uploadurl;
img.Attributes.Add(
"onmouseover", "this.src='Skins/" + skinname + "/Uploadhover.gif';");
img.Attributes.Add(
"onmouseout", "this.src='Skins/" + skinname + "/Uploadnormal.gif';");
item.Cells[3].Controls.Add(img);
Now i add the Button control to the datagrid..
pls tell me .. how can i handle the click event of the button inside the DataGrid??
waiting for ur valuable reply
thankyou
-
November 6th, 2006, 03:26 AM
#5
Re: Datagrid with DropdownMenu and Button
Hi,
In your datagrid you can add several commands to react to your actions.
if you want for example add a row using that button :
In your datagrid you add the following :
<aspatagrid runat="server".... onItemcommand="Add_Item" ... >
your button is correct, but just add the item "Commandname":
<asp:TemplateColumn HeaderText="File Name">
<ItemStyle Wrap="False" />
<HeaderStyle CssClass="orderIdItem" Wrap="False" />
<ItemTemplate>
<asp:ImageButton ID=Upload CommandName="InsertItem" runat=server />
</ItemTemplate >
</asp:TemplateColumn>
Codebehind :
Sub AddItem(ByVal sender As Object, ByVal e As DataGridCommandEventArgs)
If e.CommandName = "InsertItem" Then
'DO What you want
'To get your dropdownlistitem
Dim Lstdropdown As DropDownList = _
e.Item.FindControl("ddlname")
.... use its value
dim iListID as integer
iListID = LstAfdeling.SelectedItem.Value
....
end if
end sub
Hope it works out
greetz
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|