How to Bind Datagrid Pass Dropdown value


Description

Here bind datagrid Customize records for ex select Dropdown value 1 datagrid bind one record.try this

client Side


< html xmlns="http://www.w3.org/1999/xhtml" >
< head runat="server">
< title> Untitled Page< /title>
< /head>
< body>
< form id="form1" runat="server">
< br />
< asp:DropDownList ID="drp1" runat ="Server" AutoPostBack="True">
< /asp:DropDownList>
< asp:DataGrid ID="Dtg1" runat ="Server" AutoGenerateColumns ="false">
< Columns>
< asp:TemplateColumn HeaderText ="Sno">
< ItemTemplate>
< asp:TextBox ID="txtid" runat ="Server" Text ='< %# Databinder.eval(Container,"Dataitem.id") %> '> < /asp:TextBox>
< /ItemTemplate>
< /asp:TemplateColumn>


< asp:TemplateColumn HeaderText ="Name">
< ItemTemplate>
< asp:TextBox ID="txtName" runat ="Server" Text ='< %# Databinder.eval(Container,"Dataitem.Name") %> '> < /asp:TextBox>
< /ItemTemplate>
< /asp:TemplateColumn>

< asp:TemplateColumn HeaderText ="Empno">
< ItemTemplate>
< asp:TextBox ID="txtEmpNo" runat ="Server" Text ='< %# Databinder.eval(Container,"Dataitem.EmpNo") %> '> < /asp:TextBox>
< /ItemTemplate>
< /asp:TemplateColumn>

< asp:TemplateColumn HeaderText ="Amount">
< ItemTemplate>
< asp:TextBox ID="txtAmount" runat ="Server" Text ='< %# Databinder.eval(Container,"Dataitem.Amount") %> '> < /asp:TextBox>
< /ItemTemplate>
< /asp:TemplateColumn>


< /Columns>
< /asp:DataGrid>





< /form>
< /body>
< /html>


server Side

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Cls1 = New ClsConnect
If Not IsPostBack Then
Lstit()
End If

End Sub
Private Sub Lstit()
For i As Integer = 1 To 10
drp1.Items.Add(i)
Next
End Sub
Protected Sub drp1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles drp1.SelectedIndexChanged
Dim dt As Data.DataTable
dt = Cls1.Crtb("Select top " & drp1.SelectedItem.Text & " id,Name,EmpNo,Amount from tbemployee", "sdr")
Dtg1.DataSource = dt
Dtg1.DataBind()
End Sub


Comments

Author: Kiran06 Aug 2009 Member Level: Bronze   Points : 1

Thanks for your nice post.

Kiran,


-------------------------------
http://india-jobs-opening.blogspot.com/



  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: