我有一个树视图。我想格式化附加的字符串,如网格视图:
<ItemTemplate>
<asp:Label ID="lbut_subject" runat="server"
Text='<%#Eval("Inquiry_subject").ToString().Length > 10 ? Eval("Inquiry_subject").ToString().Substring(0,10)+"..." :Eval("Inquiry_subject") %>'
ToolTip='<%# Bind("Inquiry_subject") %>'></asp:Label>
</ItemTemplate>
我怎么希望这与我的树视图有关:
<asp:TreeView ID="TV_Question_Summary" runat="server" ImageSet="Simple" ShowLines="True" OnTreeNodeDataBound="TV_Question_Summary_DataBound" SkipLinkText="">
<DataBindings>
<asp:TreeNodeBinding DataMember="Root" FormatString=" {0}" TextField="" ValueField=""/>
<asp:TreeNodeBinding DataMember="ParentNode" FormatString=" {0}" TextField="Inquiry_id" ValueField="Inquiry_id"/><asp:TreeNodeBinding DataMember="Node" FormatString=" {0}" TextField="body" ValueField="Inquiry_id" ToolTip="body"/>
</DataBindings>
</asp:TreeView>
我想像......如果节点提交的正文字符串溢出没有 15 个字符......
对于绑定文本,我使用以下代码:
void fill_Tree()
{
using (SqlConnection conn = Util.GetConnection())
{
conn.Open();
SqlCommand SqlCmd = new SqlCommand("Select * from tbl_Inquiry_History Where (IsDisplay='True')", conn);
SqlDataReader Sdr = SqlCmd.ExecuteReader();
SqlCmd.Dispose();
string[,] ParentNode = new string[100, 2];
int count = 0;
while (Sdr.Read())
{
ParentNode[count, 0] = Sdr.GetValue(Sdr.GetOrdinal("Inquiry_id")).ToString();
ParentNode[count++, 1] = Sdr.GetValue(Sdr.GetOrdinal("Inquiry_id")).ToString();
}
Sdr.Close();
for (int loop = 0; loop < count; loop++)
{
TreeNode root = new TreeNode();
root.Text = ParentNode[loop, 1];
root.NavigateUrl = "~/Admin/OWM_Inquiry.aspx?inquiryid="+ ParentNode[loop, 1];
SqlCommand Module_SqlCmd = new SqlCommand("Select * from tbl_Question where (Inquiry_id = @parent_id AND IsCount='False')", conn);
Module_SqlCmd.Parameters.AddWithValue("@parent_id", ParentNode[loop, 0]);
SqlDataReader Module_Sdr = Module_SqlCmd.ExecuteReader();
while (Module_Sdr.Read())
{
TreeNode child = new TreeNode();
child.Text = Module_Sdr.GetValue(Module_Sdr.GetOrdinal("body")).ToString();
child.NavigateUrl = "~/Admin/OWM_Inquiry.aspx?inquiryid="+ParentNode[loop, 0];
root.ChildNodes.Add(child);
}
Module_Sdr.Close();
TV_Question_Summary.Nodes.Add(root);
}
TV_Question_Summary.CollapseAll();
}
}
请帮我...