下拉列表和嵌套的griview [英] Dropdownlist and nested griview

查看:114
本文介绍了下拉列表和嵌套的griview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨朋友,请帮助我,

我有两个下拉列表和两个嵌套的GridView。在第一个dropdwnlist大陆和第二个国家。我想将两个GridView绑定到GridView中。在第一个GridView我想要状态和第二个GridView我想要填充区。

当我在第一个dropdwnlist中选择大陆时,第二个dropdwnlist填充那些国家。当我选择第二个dropdwnlist的国家/地区时,如何填充嵌套的GridView状态和区域。我可以在ASP.NET C#中完成吗。请帮帮我。

解决方案

我想没有必要使用GridView。一个是依赖于其他人。因此,您可以使用 CascadingDropDown [ ^ ]



示例 - 使用asp的 Ajax Cascading Dropdownlist示例与数据库.net [ ^ ]


你可以通常的方式绑定第一个gridview,将coutry下拉选择值传递给gridview bound。对于第二个网格视图,你可以在第一个gridview itembound事件中将其作为bis



protected void grdState_ItemDataBound(object sender,RepeaterItemEventArgs e)

{

if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)

{

DataTable DT = new DataTable();

// U可以在Hidden Filed of State GridView中设置StateId并在此处访问它。

HiddenField StateID =(HiddenField)e .Item.FindControl(HidStateId);

GridView grvTemplateinfo;

SqlDataADapter Sqlda =新的SqlDataAdapter(你的cmd,连接);

Sqlda.Fill(DT);

grdDistrict =(GridView)e.Item.FindControl(grdDistrict);

if(DT.Rows.Count> ; 0)

{

grdDistrict.RowStyle .Wrap = true;

grdDistrict.DataSource = DT;

grdDistrict.DataBind();

}



}

}

希望这有帮助


如果你不熟悉Ajax,你可以使用J查询



https://github.com/dnasir / jquery-cascading-dropdown [ ^ ]

Hi Friend, Please Help me,
I have two dropdownlists and two nested GridViews. In first dropdwnlist continents and second countries. I want to bound two GridView into GridView. In first GridView i want to States and second GridView i want fill District.
When i select continents in first dropdwnlist then second dropdwnlist fill that countries. When i select second dropdwnlist's countries, then how to fill nested GridView States and Districts. Can I do it in ASP.NET C#. Please Help me.

解决方案

I guess there is no need to use GridView. One is dependent on other. So, you can use CascadingDropDown[^] for this type of work.

Example - Ajax Cascading Dropdownlist Sample with database using asp.net[^]


u can bind first gridview in usual way passing the coutry dropdown selected value to gridview bound. For the second gridview u hav to boud it in first gridview itembound event as tis

protected void grdState_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
DataTable DT = new DataTable();
// U can set the StateId in Hidden Filed of State GridView and access it here.
HiddenField StateID = (HiddenField)e.Item.FindControl("HidStateId");
GridView grvTemplateinfo;
SqlDataADapter Sqlda=New SqlDataAdapter("Your cmd ","Connection");
Sqlda.Fill(DT);
grdDistrict = (GridView)e.Item.FindControl("grdDistrict");
if (DT.Rows.Count > 0)
{
grdDistrict.RowStyle.Wrap = true;
grdDistrict.DataSource = DT;
grdDistrict.DataBind();
}

}
}
Hope this helps


If you are not familiar with Ajax, You can use J query

https://github.com/dnasir/jquery-cascading-dropdown[^]


这篇关于下拉列表和嵌套的griview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆