C# Tutorials and offshore development in India
Tutorials Resources Forum Reviews Communities Interview Jobs Projects Training Videos


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...


Birthday Greetings
Learn Windows 7: How to move the file from one folder to the other folder in Epic Browser   In this resource I will explain how to move the file from one folder to the other folder in Epic Browser.



Forums » .NET » .NET »

linkbutton in datagrid (handling events)


Posted Date: 14 Nov 2005      Posted By:: madhavi    Member Level: Bronze    Member Rank: 0     Points: 2   Responses: 2



hi,
1)i have a datagrid and in that one column is date. date column has all link buttons. when we click the link button it should take to another page (different pages for different link buttons).
can any one tell me how to handle the events in selected index changed event and on page load event.

2)the 2nd column is "name " column, name column can contain single name or multiple names.if it is single name it should bind regularly. if i there r multiple names then a dropdownlist should come and all the names should come in dropdown list. can any one tell me how to handle in code these things.







Responses

Author: Kiran Kumar Pinjala     Member Level: Silver      Member Rank: 0     Date: 14/Nov/2005   Rating: 2 out of 52 out of 5     Points: 2

Here is how you can use the link button.

<asp:HyperLinkColumn Target="_self" DataTextField="ProductName" SortExpression="ProductID" HeaderText="ProductID Link"
NavigateUrl="http://www.dotnetspider.com"></asp:HyperLinkColumn>

Put this within the Columns tag of the <asp:datagrid> tags.

you can replace the NavigateUrl attribute with any url.



Author: mohd. asif     Member Level: Silver      Member Rank: 0     Date: 17/Nov/2005   Rating: 2 out of 52 out of 5     Points: 2

hi
the solution of ur first question is given by Kiran os absolutely correct.
the solution of second question is this

<asp:TemplateColumn SortExpression="empName" HeaderText="Employee Name">
<HeaderStyle Wrap="False" HorizontalAlign="Center"></HeaderStyle>
<ItemStyle Font-Underline="True" Font-Bold="True" HorizontalAlign="Left" ForeColor="Blue"></ItemStyle>
<ItemTemplate>
<asp:hyperlink style="cursor:hand" Runat="server" ID="empName">
<%# Container.dataitem("empName")%>
</asp:hyperlink>
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList ID="Emp_Name" Runat=server AutoPostBack=False text='<%# container.dataitem("empName") %>'>
</asp:DropDownList>
</EditItemTemplate>
</asp:TemplateColumn>

addthis column in ur html page.
on the code page

on the datagrid1_ItemDataBound on event write this.

If e.Item.ItemType = ListItemType.EditItem Then
Dim tblEmpName As New DataTable
Dim tblSelectEmp As New DataTable
Dim subtask_id As Integer = CInt(Datagrid1.DataKeys(e.Item.ItemIndex))
Dim empName, empDept As DropDownList
empName = CType(e.Item.FindControl("emp_name"), DropDownList)
con = New ClassLibrary.Returndbset
con.Connect()
tblEmpName = con.GetDataTable("Select upper(a.user_id) employee,a.employee_id from employee b join login_master a on a.employee_id=b.employee_id where b.emptypeid<>2", con.conMas)
empName.DataSource = tblEmpName
empName.DataTextField = "employee"
empName.DataValueField = "employee_id"
empName.DataBind()
tblSelectEmp = con.GetDataTable("select e.employee_id eid,d.dept_id did from project_task p join employee e on e.employee_id=p.employee_id join dept_master d on e.employee_deptid=d.dept_id where p.subtask_id=" + Datagrid1.DataKeys(e.Item.ItemIndex).ToString, con.conMas)
empName.SelectedValue = tblSelectEmp.Rows(0)("eid")
con.Close()
End If

and on the update event of datagrid find the dropdown list and use that.......


Hope it will work for ur.....



Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.


Next : Is there any expert to solve this?
Previous : what is difference between String and string(data type) in c#?
Return to Discussion Forum
Post New Message
Category: .NET

Related Messages



About Us    Contact Us    Privacy Policy    Terms Of Use