|
What exactly is the problem or error?
The best way to accelerate a Macintosh is at 9.8m/sec² - Marcus Dolengo
|
|
|
|
|
there is no error message..when i compile it the data is displayed in the first gridview for which i have used sql data source..when i click on transfer i dont get the display of the second gridview..
scarface
|
|
|
|
|
Hi,
Your code seems ok. Can you send complete code (Page load). Or what error you are encouter.
Regards
Anil Pal
|
|
|
|
|
k..here's the code
here's the aspx code
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="userid"
DataSourceID="SqlDataSource1" Height="137px" Width="195px">
<Columns>
<asp:BoundField DataField="userid" HeaderText="userid" ReadOnly="True" SortExpression="userid" />
<asp:BoundField DataField="username" HeaderText="username" SortExpression="username" />
<asp:BoundField DataField="city" HeaderText="city" SortExpression="city" />
<asp:TemplateField HeaderText="select">
<ItemTemplate>
<asp:CheckBox ID="chkbx" runat="server" /></ItemTemplate></asp:TemplateField>
</Columns>
</asp:GridView>
</div>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT * FROM [user]"></asp:SqlDataSource>
<br />
<br />
<asp:Button ID="Button1" runat="server" Height="28px" OnClick="Button1_Click" Text="Transfer"
Width="82px" />
<br />
<br />
<br />
<asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" >
</asp:GridView>
</form>
here's the c# code
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
{
DataTable dt = new DataTable();
DataRow dr;
dt.Columns.Add(new DataColumn("userid"));
dt.Columns.Add(new DataColumn("username"));
dt.Columns.Add(new DataColumn("city"));
foreach (GridViewRow gr in GridView1.Rows)
{
if (((CheckBox)gr.Cells[3].FindControl("chkbx")).Checked == true)
{
dr = dt.NewRow();
dr["userid"] = gr.Cells[0].Text;
dr["username"] = gr.Cells[1].Text;
dr["city"] = gr.Cells[2].Text;
dt.Rows.Add(dr);
}
}
GridView2.DataSource = dt;
GridView2.DataBind();
}
}
}
thank you..
scarface
|
|
|
|
|
am not getting any error message..
when i compile i just get the display of first gridview and when i click on transfer there's no display of the second gridview..
scarface
|
|
|
|
|
hmmm...............
Please either remove the "AutoGenerateColumns="False"". property of second GridView i.e GridView2. Or make it true.
Cheers!
Regards
Anil Pal
|
|
|
|
|
hey thanks a lot...awesome..
it worked..
scarface
|
|
|
|
|
You welcome always
Regards
Anil Pal
|
|
|
|
|
can you help me out in this one..
now once the rows are copied in second gridview i click on a button delete below gridview 2 then i want them transferred again in first gridview..
can you help me with the code..its urgent..
scarface
|
|
|
|
|
once the row coming from gridview1 why u want to re-transfer it to the first gridview.
you can just delete it from gridview2.
|
|
|
|
|
OK,
But here is one question for you. AS you copied the some checked rows from first grid to second grid right. Now you want to add all the rows from second grid to first on click of delete button.
My question is bcz you have copied not delete the rows from first grid, hence when u r going transfer rows froms seond to first grid then there will be a duplicasy og rows in first grid.
Regards
Anil Pal
|
|
|
|
|
the thing is that once i click the selected rows from first gridview to another i have set rows.visible=false..now if i delete any of those selected rows in second gridview i want the delete rows to go back to first gridview..this is the requirement for my application..
scarface
|
|
|
|
|
then on delete command set the visible of that row true which u make false..
|
|
|
|
|
well i did try that but it does not display..
scarface
|
|
|
|
|
then on delete command first copy the data of second grid to first then fire the
delete query to delete the data.
from my point of view thier is no other alternate.
Regards
Keyur Satyadev
|
|
|
|
|
well i just used another datatable for that..this method is not efficient though keyur..
scarface
|
|
|
|
|
|
hey thanks for the link..
scarface
|
|
|
|
|
Hi,
I want to insert information's of 10 customers, so i have created a collection<customer> and added 10 customer in it.
But to insert this 10 objects i have to loop and insert 1 by 1, which i don't want
I know with ado.net i can bulk insert using dataset and DataAdapter.
But here the case is different .
How can i bulk insert without using dataset and dataAdapter, the collections of objects.
Regards
“You will never be a leader unless you first learn to follow and be led.”
–Tiorio
"Coming together is a beginning, staying together is progress, and working together is success." Henry Ford
|
|
|
|
|
Hi,
The one way is you can use StringBuilder class and concat all the 10 object query. SQl simple excute all the 10 query very fast.
Regards
Anil Pal
|
|
|
|
|
but will it be sql injection proof.
“You will never be a leader unless you first learn to follow and be led.”
–Tiorio
"Coming together is a beginning, staying together is progress, and working together is success." Henry Ford
|
|
|
|
|
|
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "insert Tbemployee(TE_VC50_EmpName,TE_VC50_EmpImg,TE_VC50_EmpDesignation,TE_NU_EmpDepId)values(@empname,@empimg,@empdes,@empdepid)";
cmd.Connection = con;
cmd.Parameters.Add("@empname", SqlDbType.VarChar,50).Value = txtname.Text;
cmd.Parameters.Add("@empimg", SqlDbType.VarChar, 50).Value = fu_img.FileName;
cmd.Parameters.Add("@empdes", SqlDbType.VarChar, 50).Value = txtdes.Text;
cmd.Parameters.Add("@empdepid", SqlDbType.Int).Value = DDLTeam.SelectedValue;
fu_img.SaveAs("D:\\ION Projects\\IonIntranet\\IonIntranet\\Images\\EmpOM\\" + fu_img.FileName);
cmd.ExecuteNonQuery();
txtname.Text = "";
txtdes.Text = "";
cmd.Dispose();
every time file upload control return null value..any advice.
|
|
|
|
|
Hi,
Hmmmm.... The path should not be hard coded.
fu_img.SaveAs("D:\\ION Projects\\IonIntranet\\IonIntranet\\Images\\EmpOM\\" + fu_img.FileName);
Please use virtual path(Server.mapPath) and the folder should be inside the application folder.
Regards
Anil Pal
|
|
|
|
|
its working when i remove update panal.. but with update panal its not working.. can we apply more than one script manager on page or more tan one update panal in one page with one script manager
|
|
|
|