2014-01-27 2 views
0

내 gridview의 템플릿 필드 인 링크 버튼이 있습니다. 나는gridviewin.net 내부의 링크 버튼에 툴팁 설정

protected void Grid_course_RowDataBound(object sender, GridViewRowEventArgs e) 
{ 


    connect con = new connect(date); 
    if (e.Row.RowType == DataControlRowType.DataRow) 
    { 
     LinkButton l = (LinkButton)e.Row.Cells[0].FindControl("Course_Name"); 
     IList<connect.Course> a = con.getCourse(l.Text); 
     var result = string.Join(",", a[0].Course_Description__c); 
     l.ToolTip = result.ToString(); 
     } 
    } 

은 첫 번째 행에 대해서만 작동, 작동하지 않는 각 row.My 코드의 LinkButton의 툴팁 등 다양한 텍스트를 설정해야합니다.

+0

반복 할 때 결과에 ​​무엇이 포함됩니까? –

+0

툴팁으로 설정해야하는 gridview의 필드를 기반으로 salesforce 객체에서 데이터를 가져옵니다. – user3065219

답변

0

인덱스로 링크 버튼의 텍스트와 해당 툴팁 텍스트를 값으로 사용하여 사전을 작성하십시오. RowDataBound() 이벤트에서 index를 사용하여 값을 검색하십시오. 툴팁으로 설정하십시오.

protected void Grid_course_RowDataBound(object sender, GridViewRowEventArgs e) 
{ 
    connect con = new connect(date); 
    IList<connect.Courses> ob= con.getCoursedetails(); 
    Dictionary<string, string> example = new Dictionary<string, string>(); 
    for (int i = 0; i < ob.Count; i++) 
     example.Add(ob[i].Name.ToString(), ob[i].Course_Description__c.ToString());//Setting Values to dictionary 
    if (e.Row.RowType == DataControlRowType.DataRow) 
    { 
     LinkButton l = (LinkButton)e.Row.Cells[0].FindControl("Course_Name"); 
     l.ToolTip = example[l.Text].ToString();//Retrieving values using index from dictiory. 

    } 
}