|
Hi,
I'm working on a asp.net project with a datagrid. I want the user to be adding data into Sql database using the datagrid. So I'm using a ListBox to do this and edit update and delete. I placed listbox in EditItemTemplate and label in ItemTemplate. but when I try now to edit it does not bring the lisbox but i can read the grid with the sql content. my code actually looks like this:
public void Edit_dgid(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
dgid.EditItemIndex = e.Item.ItemIndex;
BindDataGrid();
}
public void Cancel_dgid(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
dgid.EditItemIndex = -1;
BindDataGrid();
}
public void Update_dgid(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
System.Web.UI.WebControls.ListBox st=new System.Web.UI.WebControls.ListBox();
st=(System.Web.UI.WebControls.ListBox)e.Item.Cells[5].FindControl("lbachobj");
System.Web.UI.WebControls.ListBox st1=new System.Web.UI.WebControls.ListBox();
st=(System.Web.UI.WebControls.ListBox)e.Item.Cells[4].FindControl("lbobj");
SqlCommand myCommand=new SqlCommand();
myCommand.Connection=con;
myCommand.CommandText="insert into Object,AchievedObject where @Object,@AchievedObject";
myCommand.Parameters.Add(new SqlParameter("@AchievedObject",SqlDbType.Text));
myCommand.Parameters["@AchievedObject"].Value=st.SelectedValue;
myCommand.Parameters.Add(new SqlParameter("@Object",SqlDbType.Text));
myCommand.Parameters["@Object"].Value=st1.SelectedValue;
con.Open();
myCommand.ExecuteNonQuery();
con.Close();
dgid.EditItemIndex=-1;
BindDataGrid();
}
Thanks.
|
|
|
|
|
Hello,
We have created user control using data grid in VB.Net. In this datagrid we are dispalying for each row edit and delete icon.
If user does not have access then we don't want to display edit & delete icon, but some blank space is coming in place of icons.
We don't want this blank space if user does not have access for edit & delete.
Can somebody give sample code how to remove that blank space.
Thanks & Regards,
Kumar
|
|
|
|
|
Hide the Datagrid column instead of hiding the icons,
Add the code below on Page_Load.
<br />
If IsUserHasAddDelEditAccess = False Then<br />
<br />
'Hide Columns for Add, Edit and Delete<br />
<br />
'Add Column<br />
DataGrid1.Columns(10).Visible = False<br />
<br />
'Edit Column<br />
DataGrid1.Columns(11).Visible = False<br />
<br />
'Delete Column<br />
DataGrid1.Columns(12).Visible = False<br />
<br />
End If<br />
Regards,
Mark
|
|
|
|
|
Another Option for you.
1. Add an image and imagebutton to your datagrid add column
2. Set the image visibility to false. this image will represent a user have no access.
3. Override the DataGrid ItemDataBound Event. for your reference see the code below.
Private Sub DataGrid1_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles DataGrid1.ItemDataBound<br />
<br />
<br />
If IsUserHasAddDelEditAccess = False Then<br />
<br />
Dim imgbAdd As ImageButton = CType(e.Item.Cells(0).FindControl("imgButtonAdd"), ImageButton)<br />
imgbAdd.Visible = False<br />
<br />
Dim imgAddGrey As WebControls.Image = CType(e.Item.Cells(0).FindControl("imgAddGrey"), WebControls.Image)<br />
imgAddGrey.Visible = True<br />
<br />
' Do the same thing with Edit and Delete<br />
<br />
End If<br />
<br />
<br />
End Sub<br />
<br />
<br />
Regards,
Mark
|
|
|
|
|
Thanks a lot. First one code is working for us.
Thanks & Regards,
Kumar
|
|
|
|
|
Respected Gurus
in frmShowRefForm.aspx
Public ReadOnly Property getRef_No() As String
Get
Return txtRefNo.Value
End Get
End Property
this property returns the value of txtRefNo.
This property works fine if i m using it on the same page.
But not from other page from where i want to access the value of txtRefNo.
in page_load event of other page
Dim obj As frmShowRefForm
obj = New frmShowRefForm
Dim ref_no As String
If obj.getRef_No <> "" Then
ref_no = obj.getRef_No
End If
Error"Object Reference not set to an instance of an object."
this error comes while returning the value of the textbox of frmShowRefForm.
I have tried to return a string variable from the property instead of the textbox value and it works fine..
Plz guide
|
|
|
|
|
You will need to do a Server.Transfer in order to maintain the other pages's values then you will need to do something with the Context.Objectsendingpage in order to access the pages in this way I believe.
Cleako
|
|
|
|
|
i have a datafield of date time but i want to display only the date.
how do we split this string .
thanks in advance
|
|
|
|
|
DateTime.Now.ToShortDateString().ToString();
Regards,
Sylvester G
Senior Software Engineer
Xoriant Solutions
sylvester_g_m@yahoo.com
|
|
|
|
|
date_datafield.ToString("MM/dd/yyyy");
Regards,
Mark
|
|
|
|
|
Hi
Date Time in any format.
Example:
System.Globalization.DateTimeFormatInfo DFI = new System.Globalization.DateTimeFormatInfo();
DFI.ShortDatePattern = "MM/dd/yyyy";
String StrDate = DateTime.Now.ToString("d", DFI);
Harini
|
|
|
|
|
I have created 2 forms then in first form I am creating object of second form
Then When Second form will be closed at that time i want to make changes in first
form then how can i do it?
I mean which events should be written?
Anita
|
|
|
|
|
you can use like this <body onunload="javascriptfunction()">
Regards,
Sylvester G
Senior Software Engineer
Xoriant Solutions
sylvester_g_m@yahoo.com
|
|
|
|
|
Then this is the wrong place to post a message. Post it under C#
Regards,
Sylvester G
Senior Software Engineer
Xoriant Solutions
sylvester_g_m@yahoo.com
|
|
|
|
|
.NET 2003
We have a requirement to read an html file stored in a folder and display it in an aspx page. When printout is taken, we have need to have header and footer(dynamic) in all the printed pages. Will that be possible to manipulate browser's(IE/Firefox/Netscape) header and footer so that it appears on all the pages? Can this be achieved using Crystal Reports? Will that be possible to read HTML file and show its contents in Crystal Reports based on the URL passed as a parameter to Crystal Reports?
|
|
|
|
|
|
|
|
how to use response.form ? give me an example
|
|
|
|
|
|
Hi! just like Click event hadler for ASP.NET Button control: Button1_Click(object sender, EventArgs e) for single click, i want to develop Button1_DoubleClick(object sender, EventArgs e) event handler for double click for the ASP.NET Button Control. Can any one help me????
Thanks & Regards,
SAMir Nigam,
Software Developer,
STPL, Lucknow, India.
|
|
|
|
|
I'm not very sure why you need "DoubleClick" Event for button..
maybe.. you can try to do "HTTP POST" ondblclick of button.
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
If you want to thank me for my help, please vote my message. Thank you.
|
|
|
|
|
its my Team Lead's requirement. if you have any idea regarding this please prove me link
Thanks & Regards,
SAMir Nigam,
Software Developer,
STPL, Lucknow, India.
|
|
|
|
|
Hi all,
I have to apply css to file Upload control of ASP.NET 2.0.
I need apply css to textbox and the button.
Please tell me how to do this.
Thanks in advance.
|
|
|
|
|
>>I have to apply css to file Upload control of ASP.NET 2.0.I need apply css to textbox and the button.
it can't be done with a trick..
Trick #1. (IE)
1. Set display style of "input file" to "none"
2. Add one button.
3. Write javascript function ("fileId.click();") in button click.
[Note: it works only in IE.]
Trick #2. (Cross-browsers)
1. Set transparency of "input file" to 0
2. Place one button (btnFileBrowse) above the button of "input file" [Make sure the z-order of "input file" is higher than "btnFileBrowse"]
Please check this article.
Styling an input type="file"
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
If you want to thank me for my help, please vote my message. Thank you.
|
|
|
|